How to do a All() using Dynamic LINQ

dynamic-linq linq

Question

as the same as here: How to do a Sum using Dynamic LINQ I want to do a All() with a dynamic string...

My code:

allDataValid = consumptionModelListOld.All(x => x.F11ValueValid);

I want to write:

allDataValid = consumptionModelListOld.All("F11ValueValid");

How to do this?

1
0
5/23/2017 12:30:12 PM

Accepted Answer

There is no All "operator", and it would be quite difficult to create it... but you could:

allDataValid = !consumptionModelListOld.Where("!F11ValueValid").Any();

Note the use of ! (twice, to negate the F11ValueValid and to negate the result of Any()).

3
8/10/2015 12:56:31 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow