I\'m looking for possible ways to persist the following classes. Subsonic SimpleRepository looks like it might work, and people have said it should, when I
I'm not sure I'm going to answer everything you're asking here, but if I was implementing this using SimpleRepository I'd have the following models:
public class RawYValue
{
public int Id { get; set; }
public int RunDatumId { get; set; }
public float YValue { get; set; }
}
public class RunDatum
{
var repo = new SimpleRepository();
public int Id { get; set; }
public int DataId { get; set; }
public DateTime StartDateTime { get; set; }
public TimeSpan ElapsedTime { get; set; }
public IQueryable<RawYValue> RawYValues
{
get { return repo.Find<RawYValue>(rawYValue => rawYValue.RunDatumId == Id); }
}
}
public Data
{
var repo = new SimpleRepository();
public int Id { get; set; }
public string OperatorId { get; set; }
public string SampleId { get; set; }
// CAN SUBSONIC DEAL WITH THIS ARRAY OF OBJECTS???
public IQueryable<RunDatum> RunData
{
get { return repo.Find<RunDatum>(runDatum => runDatum.DataId == Id); }
}
}
I imagine SubSonic will have trouble pluralising some of the names so you may need to change them but hopefully this will get you started.
To answer my own question...
Despite some other postings I found which imply that Subsonic SimpleRepository can automatically generate a relational schema from an object model, this turns out NOT to be the case. See Rob Conery's answer to this question:
relationships-and-lazy-loading-in-subsonic-3-0
He's working on it, however, and it will probably be well worth the wait.
In the meantime, I've looked at Fluent NHibernate, and this does what I want right out of the box. Their source code download has a demo project called Examples.FirstProject which demonstrates the functionality I'm looking for. Their documentation seems to be much more mature as well.
However, NHibernate also appears more complex overall, so it will be interesting to see what develops with Subsonic.
Edit: Heres a useful link that shows how to mangage foreign keys yourself in SimpleRepository -
subsonic-3-simplerepository
Have not tried it myself, but looks like it would actually work.