Left Joins in LINQ with multiple Critieria?

From s in db. TblCustomerPricingSchemes . Where(x => c.

CustomerID == x. CustomerID && x. PSLangPairID == l.

LangPairs).DefaultIfEmpty().

Try from c in db. TblCustomer from s in db. TblCustomerPricingSchemes.

Where(w => w. CustomerID == c. CustomerID).DefaultIfEmpty() from p in db.

TblPricingSchemes. Where(w => w. PSLangPairID == l.

LangPairs).DefaultIfEmpty() where t. JobID == jobID select c // etc.

You have two options. Firstly, use the navigational properties. I've asked why people use joins instead of navigational properties a while back and the answers supported my understanding - there's rarely a real reason and it's usually a mistake.As the other answers here suggest, use some where clauses to filter your object graph.

Db. TblCustomerPricingSchemes. Where(x => condition).

Select(scheme => new { scheme, scheme. LangPair, scheme.LangPair. PricingScheme }); However if you need to join, then you try allowing for the outer join in your where clause by doing some null checks.

Where t. JobID == jobID && (s. PSLangPairID == null || l.

LangPairs == null || s. PSLangPairID == l. LangPairs) && (p.

PSDescID == null || c. PricingID == null || p. PSDescID == c.

PricingID) if it were SQL you use a coalesce operator, but not sure if this would work and again depends on whether you're using LINQ-to-SQL or Entity Framework. && (s. PSLangPairID?

L. LangPairs) == l. LangPairs && (p.

PSDescID? C. PricingID) == c.PricingID.

I love feedback on downvotes. – Kirk Broadhurst Sep 28 at 23:30.

I have a left join that has multiple filtering criteria. If I put them into the where clause then it basically becomes an inner join, rather than a left join. Please would someone let me know how I can incorporate the additional criteria in my LINQ join statement.

Thanks in advance,Polly AnnaHere is my SQLSELECT D.Name, D. TotalCostFROM tblInvoiceContractHireRecharges RÂ Â Â Â Â LEFT JOIN tblAllocation AÂ Â Â Â Â Â Â Â Â Â Â Â Â ON A. REgNo = R.

RegNo         AND A.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions