Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A LINQ lookup dilemma
Message
From
30/06/2008 00:39:22
 
 
To
30/06/2008 00:14:10
General information
Forum:
ASP.NET
Category:
LINQ
Miscellaneous
Thread ID:
01327573
Message ID:
01327574
Views:
7
I don't believe it!!! I found a solution: the trick is some magic called DefaultIfEmpty()

I found an example at http://www.hookedonlinq.com/OuterJoinSample.ashx

I had to set up my own Joins (rather that using the "built-in" associations from my dbml), but at least it works exactly like I wanted. (I've spent about 2-3 hours working on this)

Code:
           IEnumerable<JobItemsUI> JobItems = from a in db.JobItems
                                              join p in db.Parts on a.part_no equals p.part_no into g
                                              where a.job_num == JobNo
                                              orderby a.item
                                              from p in g.DefaultIfEmpty()
                                              select new  JobItemsUI (a.qty, a.part_no, a.dwg_no,
                                              p==null? a.desc : p.desc,
                                              a.price);
Previous
Reply
Map
View

Click here to load this message in the networking platform