I am trying to Filter a list on Multiple columns. I know I can loop thru the list collection and filter the records, is there any better way?
My first criteria is colA != “X” and if colA == “Y”than check for colB value for this type only.
I have to allow all values on colA except “X” and if ColA == “Y” && colB == “T” ( I check colB value only if ColA == “Y”) I am not able to write this.
Basically if ColA == “X” then don’t allow and if ColA == “Y” then check for colB value and filter depending on the value. Allow rest of all ColA values.
Accounts = Accounts.Where(acc => acc.ColA != “X” || ??).ToArray();
Something like this should work if I am understanding your question correctly.
However, I think this is more readable: