missolonghi (1) [Avatar] Offline
#1
Hi all,

I have a quick LINQ-to-SQL subquery question which I would really appreciate some pointers on.

Supposing a large db with a parent table, child table, and subchild table. Something like Northwind's Customer, Order, and OrderLines.

I want to construct an XML document with information for all orders, partially based on data from the Order, and partially OrderLines tables, if and only if there are entries in OrderLines. I.e. there could be a blank order waiting to go but as this has not been filled out with related OrderLines it is not of interest.

Being new to LINQ I am slightly swimming with the best syntax necessary to get two typed entities Order and OrderLines in related fashion such that I can iterate through the relation and populate my XML document as described with information from each.

Any pointers would be greatly appreciated.
jwooley (123) [Avatar] Offline
#2
Re: Subquery question
Look at using "Any" as discussed in chapter 6 to find any records that have liens. In addition, since you know you will always fetch the associtated Orders and OrderLines with the Customers, you will likely want to specify the DataLoadOptions which we cover also in chapter 6 to avoid excessive round-trips to the database.

Jim