views:

342

answers:

2

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?

+1  A: 

There is no eager loading, and DeepSave in ActiveRecord only calls Save. Here is an example with Northwind Order class foreign key method.

[Test]
public void SelectOrderDetails()
{
    Order order = new Order(10250);
    OrderDetailCollection details = order.OrderDetails();
    Assert.IsTrue(details.Count == 3);
}
P a u l
+1  A: 

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.

Rob Conery