I’m trying to filter a set of records based on a sub-object’s criteria. This compiles ok
recordList = recordList.Where(r => r.Areas.Where(a => a.Area == "Z").Count() > 0);
but this doesn’t
recordList = recordList.Where(r => r.Areas.Where(a => a.Area <= "Z").Count() > 0);
giving these errors
Cannot convert lambda expression to type ‘string’ because it is not a delegate type
Delegate ‘System.Func’ does not take ‘1’ arguments
Operator ‘<=’ cannot be applied to operands of type ‘string’ and ‘string’
!= works ok, by any sort of less than or greater than operation fails.
This has got nothing to do with LINQ not allowing the use of <=, but that strings cannot be compared with this operator (yet can obviously use equal or not equal).
Writing this in a console app:
Underlines the final line with (basically) the same error
Now, you can use the <= operator on
char, so the similar code below compiles and works as expected:So maybe what you want is:
HTH.