A predicate is a method that defines a set of criterias and can be used as a parameter

test

The .where extension method accepts a lambda expression as parameter. This parameter is called a predicate but in fact is a Expression.

If you want to use this in your own class you need to define the predicate like this:

 

   public List <T> Getlist<T>(Expression<Func<T,bool>> expression) 
      where T : class 
    { 
      return context.CreateObjectSet<T>().Where(expression).AsParallel().ToList(); 
    } 

The .find extension methods accepts a parameter which if ofType Predicate. This Predicate parameter is static boolean method. Example:

 public static bool StartWithA(string entry) { if (lijst.StartsWith("A", StringComparison.InvariantCultureIgnoreCase)) return true; else return false; } 

Example find method with this predicate:

 private List lijstje = new List(); Private List GetAllAentrys() { return lijstje.Find(StartWithA); } 

Which allso can be used with a lambda expression like this ( where the diffence is that find returns a single and where an enumrable:

 lijstje.Find( a => a.StartsWith ("a")); lijstje.Where( a => a.StartsWith ("a")); 

Both lambda expression are here filtering parameters so it are predicates where the find parameter is ofType Predicate and the where paremeter is ofType expression. Confusing??

adfssdaf

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!