tags:

views:

13

answers:

1

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" , but when it returns the Order from database, OrderItems Property is empty, how can i get order with related orderItems ??

A: 

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.

Randy Minder