{
new Employee{ID=1, Name="The"},
new Employee{ID=2, Name="Foo"}
};
//Employee the = Array.Find(employees, FindThePredicate);
Employee the = Array.Find(employees, e=>e.Name == "The");
Comprehensive Query Syntax
Collection
IEnumerable<Employee> query1 =from e in employees
where e.Name == "The"
orderby e.ID ascending
select e;
Single Item
Employee query1 =(from e in employees
where e.Name == "The"
orderby e.ID ascending
select e).First();
Extension Methods with Lambda Expressions
Collection
IEnumerable<Employee> query2 =employees.Where(e=>e.Name=="The")
.OrderBy(e=>e.ID)
.Select(e=>e);
Single Item
Employee query2 =employees.Where(e=>e.Name=="The")
.OrderBy(e=>e.ID)
.Select(e=>e)
.First();
No comments:
Post a Comment