Rey Norbert Besmonte
Rey Norbert Besmonte

Reputation: 791

c# LinQ Update with multiple where

I'm stuck in using LinQ, I can update using 1 filter but when using multiple it ignores the other 2 and just check the first one.

Here is the code that I am using:

One where that is working:

Engagement_History eh = qdb.Engagement_History.First(a => (a.pdPPMCID.Equals(PPMCID));

Multiple Where that is not working:

Engagement_History eh = qdb.Engagement_History.First(a => ((a.pdPPMCID.Equals("1")) && (a.ehMonth.Equals("1")) && (year.Equals("2016"))));

Upvotes: 0

Views: 103

Answers (1)

ChrisF
ChrisF

Reputation: 137128

In your query you have just

year.Equals("2016")

as your final clause.

This should be:

a.year.Equals("2016")

Otherwise it's going to be looking for a local variable called year to compare "2016" against. If that local variable doesn't exist then you should be seeing a compiler error. If it does exist then the query will only return results if it's set to "2016".

Upvotes: 3

Related Questions