linq

来源:互联网 发布:淘宝飞利浦吹风机 编辑:程序博客网 时间:2024/06/05 03:20

linq中有一个这样的有趣问题!!

private bool TestEmployee(EmployeeDetails employee)
{
return employee.LastName.StartsWith("D")
}

 

IEnumerable<EmployeeDetails> matches;
matches = from employee in employees
where TestEmployee(employee)
select employee;

 

这个where条件中用的一个function的返回值

 

 

linq的格式:

 

      var variable=from tempObject in ListObject

                           where ........

                           order by .......

                           select tempObject

 

 

linq中的group by 格式

      var variable=from tempobject in ListObject

                           group tempObject  by tempObject.property  in tempGroupByObject  (这里要一个新的变量)

                           select tempGroupByObject

 

linq中的lambda 表达式,lambda表达式其实是一个可扩展方法,操作符号是“=》”

      var variable=ListObject.select(tempObject=>tempObject)

原创粉丝点击