Martin Martin
27.01.2016 20:57

Code-Snippet: LINQ - outsource where condition

Sometimes you need to look for specific objects in several linq queries. Therefore its very important to query the objects in the exactl same way in every query.

In this case, it makes sense to store the WHERE LINQ statments in a predicate variable. Then you can reuse it in all linq queries.

This sample code is simplefied and for demonstration:

Predicate<DateTime> dateTimePredicate = b => b.Hour == 1;
        List<DateTime> dateTimeList = new List<DateTime>()

Schlüsselwörter: LINQ, Where, Predicate
zuletzt geändert: 27. Jšnner 2016 21:18
Link zu diesem Artikel: (in die Zwischenablage)