0

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?

Community
  • 1
  • 1
Rene Koch
  • 317
  • 3
  • 13

1 Answers1

3

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()).

xanatos
  • 109,618
  • 12
  • 197
  • 280
  • @AlexH On my version of Dynamic Linq (I'm using [this one](https://www.nuget.org/packages/System.Linq.Dynamic/)), there is no `.Any(string)` overload. – xanatos Aug 10 '15 at 13:08