你的位置:首页 > ASP.net教程

[ASP.net教程]linq lambda let


1.linq let用法

var query = from x in db.Userslet theage = x.agelet sexstring = x.sex ? "男" : "女"where theage > 30 && sexstring == "男";select x;

 

等效

2.lambda let写法

var query = db.Users.Select(x => new { x, theage = x.age }).Select(x => new { x, sexstring = x.sex ? "男" : "女" }).Where(x => x.x.theage > 30 && x.sexstring == "男").Select(x => x.x.x);

摘自:http://bbs.csdn.net/topics/380267995

 

From:http://www.cnblogs.com/xuejianxiyang/p/5505538.html