RcBuilder@walla.com
call centre: 054-5614020

Predicate query

23
Sep
2014
Posted by: RcBuilder  /   Category: IEnumerable / Interfaces / Lambda / Linq / Predicate / SOURCE CODE   /   No Comments

Predicate query

user entity

public class User{
public int Id{set;get;}
public string Name{set;get;}
public byte Age{set;get;}

public static List<User> users = new List<User>() {
{new User(){ Name = “ROBY”, Age= 30, Id = 1}},
{new User(){ Name = “ISAAC”, Age= 20, Id = 2}},
{new User(){ Name = “AVI”, Age= 17, Id = 3}},
{new User(){ Name = “RON”, Age= 40, Id = 4}},
{new User(){ Name = “TAMIR”, Age= 36, Id = 5}},
{new User(){ Name = “ITAY”, Age= 39, Id = 6}}
};
}

predicate query 

public IEnumerable<User> Filter(Func<User, bool> query)
{
return User.users.Where(query);
}

USING

var users_over_30 = Filter(x => x.Age > 30);
var users_under_30 = Filter(x => x.Age < 30);
var users_startWith_R = Filter(x => x.Name.StartsWith(“R”));

Author Avatar

About the Author

בניית אתרים ופתרונות טכנולוגים | RcBuilder

No Comments


  • פיתוח מערכות
  • פתרונות טכנולוגים
  • קידום אתרים
  • בניית אתרים