What is the best way to use nested Objects with Subsonic when I only have Iqueryable for Foreign Key Relationships

StackOverflow https://stackoverflow.com/questions/1529117

Question

I'd like to use Subsonic in a shopping cart application, but I'm trying to replace code that is using Session to store an Order object. That Order object has a collection or OrderDetail objects that are added to the collection through the shopping cart process. I'm impressed with what Subsonic can do and I think I'm missing how I could implement it in this project. What I need is:

Order.OrderDetails.Add(new OrderDetail());

Right now Subsonic is creating the one-to-many relationship for me based on the foreign key in the OrderDetails table. But Order.OrderDetails is available as an Iqueryable interface. I would like more control over how the property is managed. How have other managed to use the Subsonic generated objects to hold data in memory before saving to the database?

Was it helpful?

Solution

You could add another property via a partial class and use that instead of the generated one:

public partial class Order {
    public IList<OrderDetail> Details { get; set; }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top