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)

select top 10 from table where .....

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

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

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

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

问题不太明确: 用文字叙述一下你想实现的效果; 现在的结果具体哪里不对; 直接看也不方便调试,可以留联系远程看看。

xxdateContext b=new xxdateContext(); var count=from a in b.A where a.userid==1 select count(a);

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