Subsonic Deeploads: Is This Supported

deeploadsubsonic

It could very well be that I'm just missing the correct vernacular in this space, but I'm looking for a particular piece of functionality in SubSonic. In NetTiers it was called a "DeepLoad". A deep load runs to the database and fetches many objects (ie. fetch this OrderDetail and all of it's LineItems) in one database call.

Again, I want to run to the data store once an build up a potentially dense object graph or related items populated by the data store.

How do I do this in SubSonic and what is it called in SubSonic?

Best Answer

You can do this in SubSonic 3.0 (not yet released, but almost there...) using IQueryable with lazy loading:

var db=new NorthwindDB();
var order=db.Orders.Where(x=>.xID==20).SingleOrDefault();
Assert.Equal(3,order.OrderDetails.Count());

if you're not on 3 (which requires .net 3.5) you can do this with Active record as Paul mentions - but it will make two calls.