knrt.net
当前位置:首页 >> 用LINQ查询前6条数据的语句怎么写? >>

用LINQ查询前6条数据的语句怎么写?

var td = (from d in db.PositionTbl select d).Take(6);

先orderby排序一下,然后take(6) var p = db.orderby(id).take(6)

storeDB.Albums.OrderByDescending(a => a.OrderDetails.Count()).Take(count).ToList(); 数据上下文.Albums数据表.倒序排序(条件为按照各数据关联的OrderDetails数据表中数据的条数).拿记录(count条).立即执行转为list

select top 10 from table where .....

var query= (from c in db.Test orderby c.Id select c).Take(3);

var query= from m in 结果集.tolist() where m.时间字段=DateTime.Now.AddDays(-7) select new{m.字段1,m.字段2.。。。。}

var query = from a in db.表1 join b in db.表2 on a.bid equals b.id join c in db.表3 on a.cid equals c.id select new { AName=a.Name, BName=b.Name, CName=c.Name };

s = s.Where(t => t.WinningTime.IndexOf(DateTime.Now.Date) >= 0); //WinningTime是你表里面的字段 这就相当于 sql里的 like ‘% %’

大概是如下 from lst in StatusListwhere GoodsType == @GoodsTypeselect lst.TypeName

class table { public string id } private void Window_Loaded(object sender, RoutedEventArgs e) { List ls = new List(); for (int i = 0; i < 10; i++) ls.Add(new table ); int pageSize = 3; int currentPage = 2; var linq = (from t in...

网站首页 | 网站地图
All rights reserved Powered by www.knrt.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com