Linq to Entities Joins

Posted by Bob Avallone on Stack Overflow See other posts from Stack Overflow or by Bob Avallone
Published on 2011-02-07T15:22:50Z Indexed on 2011/02/07 15:25 UTC
Read the original article Hit count: 170

Filed under:
|
|
|

I have a question about joins when using Linq to Entities. According to the documentation the use on the join without a qualifier performs like a left outer join. However when I execute the code below, I get a count returned of zero. But if I comment out the three join lines I get a count of 1. That would indicate that the join are acting as inner join. I have two questions. One which is right inner or outer as the default? Second how do I do the other one i.e. inner or outer? The key words on inner and outer do not work.

 var nprs = (from n in db.FMCSA_NPR
                            join u in db.FMCSA_USER on n.CREATED_BY equals u.ID
                            join t in db.LKUP_NPR_TYPE on n.NPR_TYPE_ID equals t.ID
                            join s in db.LKUP_AUDIT_STATUS on n.NPR_STATUS_ID equals s.ID
                             where  n.ROLE_ID == pRoleId
                             && n.OWNER_ID == pOwnerId
                             && n.NPR_STATUS_ID == pNPRStatusId
                             && n.ACTIVE == pActive

                             select n).ToList();


                if (nprs.Count() == 0)
                    return null;

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET