Return object with related child objects from database
i have two tables Orders and OrderItems in my sql database, also there is an association between them, [Order.Id]~[OrderItem.OrderId].... the generated class Order By linq2sql has a property "OrderItems" type of "EntitySet" , bu开发者_运维百科t when it returns the Order from database, OrderItems Property is empty, how can i get order with related orderItems ??
L2S won't retrieve the child rows (OrderItems) until you iterate over the first Order row. You can also tell L2S to retrieve all the child rows immediately, before any parent rows are iterated over.
Hope this helps.
精彩评论