-
Notifications
You must be signed in to change notification settings - Fork 5
Home
AlbertoMonteiro edited this page Jun 16, 2011
·
12 revisions
public class Person { public string Name { get; set; } public int Age { get; set; } public bool HasCar { get; set; } }
main() { List persons = new List { new Person {Name = "Alberto",Age = 21, HasCar = False}, new Person {Name = "Pedro",Age = 26, HasCar = True } };
//I want only peoples that has car, and has 'o' on the name
var filter = new FilterExpression<Pessoa>();
filter.Start(p => p.Name.Contains("o")).And(p => p.HasCar);
foreach(var item in persons.Where(filter.ResultExpression))
Console.WriteLine(item.Name);
//Or
var filter2 = new FilterExpression<Pessoa>();
filter2 = filter2.Start(p => p.Name.Contains("o"));
filter2 = filter2.And(p => p.HasCar);
foreach(var item in persons.Where(filter2.ResultExpression))
Console.WriteLine(item.Name);
}