nested join linq-to-sql queries
Posted
by ile
on Stack Overflow
See other posts from Stack Overflow
or by ile
Published on 2010-05-20T10:38:19Z
Indexed on
2010/05/20
10:40 UTC
Read the original article
Hit count: 225
var result = (
from contact in db.Contacts
where contact.ContactID == id
join referContactID in db.ContactRefferedBies on contact.ContactID equals referContactID.ContactID
join referContactName in db.Contacts on contact.ContactID equals referContactID.ContactID
orderby contact.ContactID descending
select new ContactReferredByView
{
ContactReferredByID = referContactID.ContactReferredByID,
ContactReferredByName = referContactName.FirstName + " " + referContactName.LastName
}).Single();
Problem is in this line:
join referContactName in db.Contacts on contact.ContactID equals referContactID.ContactID
where referContactID.ContactID
is called from the above join
line. How to nest these two joins?
Thanks in advance!
Ile
© Stack Overflow or respective owner