I want to left outer join 2 tables called a and b.In the Where clause I want to check properties from both tables i.e like this

var query = from a in data.A
                    join b in data.B
                    on a.id == b.id
                    where a.marks = 1 && b.archived == false
                    into c
                    let d= c.FirstOrDefault()

But i cant check for the b.archived == false condition.How can I do this?
thnx in Advance

6 Years
Discussion Span
Last Post by davidsimmonds

Thnx for replying.It was a mistake happened when i posted the code.Still I have the problem.I want to check a property of the table which is in the right hand side of the join i.e b.archived == false.Any method that I can use for it?


I have the same problem with multiple joins. Here is the query:

Data data = (from scr in entities.SponsoredCharitableReportsSet
                             from company in entities.CompanySet.Where(c => c.ID == scr.CompanyID)
                             from user in entities.UserSet.Where(u => u.MemberID == scr.MemberID)
                             where scr.ID == DetailsID
                             orderby scr.DateRequested, company.CompanyName, user.FullName
                             select new Data
                                 ID = (company == null ? 0 : company.ID),
                                 DetailsID = scr.ID,
                                 CompanyName = (company == null ? String.Empty : company.CompanyName),
                                 Type = (company == null) ? String.Empty : company.Type,
                                 WhoReceives = scr.WhoReceives,
                                 RequestedCompanyName = scr.RequestedCompanyName,
                                 DateRequested = scr.DateRequested,
                                 RequestedCompanyID = scr.RequestedCompanyID,
                                 AmountCharged = scr.AmountCharged,
                                 InvoiceNumber = scr.InvoiceNumber,
                                 Comments = scr.Comments,
                                 FullName = (user == null ? String.Empty : user.FullName),
                                 Phone = (user == null ? String.Empty : user.Phone),
                                 MemberID = (user == null ? String.Empty : user.MemberID),
                                 SendToBusinessMembers = scr.SendToBusinessMembers,
                                 SendToResidentialMembers = scr.SendToResidentialMembers,
                                 SendToAllMembers = scr.SendToAllMembers,
                                 SendToIndividualMembers = scr.SendToIndividualMembers,
                                 SendToNonMember = scr.SendToNonMember,
                                 NonMemberEmail = scr.NonMemberEmail,
                                 IndividualMembers = scr.SendToMembersList

The SponsoredCharitableReportsSet table has a valid record. The CompanySet has a matching ID for the CompanyID in SponsoredCharitableReportsSet. The UserSet table DOES NOT have a record with a matching MemberID. I want all records from SponsoredCharitableReportsSet to come back regardless of a record in company or user. The query only returns a match if I comment out the "from user" line and any references to user. Why is this happening? There must be something wrong with my query that I dont understand.

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.