当前位置:编程学习 > C#/ASP.NET >>

求一个linq语句

我想用linq对EF实体article进行查询,查找article中articleid 不在12,23,23,26中的记录,按articleDt倒序 --------------------编程问答-------------------- var query = from a in article
            let exclude = new int[] { 12, 23, 23, 26 }
            where !exclude.Contains(a.articleid)
            orderby articleDt descending
            select a; --------------------编程问答-------------------- var query = from a in article
  let exclude = new int[] { 12, 23, 23, 26 }
  where !exclude.Contains(a.articleid)
  orderby articleDt descending
  select a; --------------------编程问答-------------------- var query = from a in article
  let exclude = new int[] { 12, 23, 23, 26 }
  where !exclude.Contains(a.articleid)
  orderby articleDt descending
  select a; --------------------编程问答-------------------- var query = from a in article
  let exclude = new int[] { 12, 23, 23, 26 }
  where !exclude.Contains(a.articleid)
  orderby articleDt descending
  select a; --------------------编程问答--------------------
引用 1 楼  的回复:
var query = from a in article
            let exclude = new int[] { 12, 23, 23, 26 }
            where !exclude.Contains(a.articleid)
            orderby articleDt descending
            select a……

修改下

var query = from a in article
   let exclude = new int[] { 12, 23, 23, 26 }
   where !exclude.Contains(a.articleid)
   orderby a.articleDt descending
   select a; --------------------编程问答--------------------
   objectList.Where(c => c.Identity != 14 && c.Identity != 13 && c.Identity != 19 && c.Identity != 23).OrderByDescending(c => c.Identity);



不在前五条的倒序
  objectList.Where(c => objectList.Skip(5).Select(d=>d.Identity).Contains(!c.Identity)).OrderByDescending(c => c.Identity); --------------------编程问答--------------------

var queryResult = (from a in db.Article 
where !(new int?[] { 14, 13,19,20 }).Contains(a.ArticleID) 
orderby a.articleCreateDT descending
select a).Take(5);
--------------------编程问答-------------------- var queryResult = (from a in db.Article 
where !(new int?[] { 14, 13,19,20 }).Contains(a.ArticleID) 
orderby a.articleCreateDT descending
select a).Take(5);
补充:.NET技术 ,  LINQ
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,