【问题标题】:Syntax for "and" and distinct operation in entity framework?实体框架中“和”的语法和不同的操作?
【发布时间】:2011-11-30 09:08:23
【问题描述】:

我想显示 accountid、id 匹配的记录,并显示不同的记录。

var result = from a in cxt.tblInventoryProducts
             where a.aid == accID && a.id == id
             select new
             {
                 a.productType,
                 a.productName
             };

提前致谢

【问题讨论】:

    标签: c# .net linq entity-framework linq-to-entities


    【解决方案1】:

    类似

    var result = from a in cxt.tblInventoryProducts
                 where a.aid == accID && a.id == id
                 group a by new { a.productType, a.productName } into grp
                 select new
                 {
                     grp.Key.productType,
                     grp.Key.productName
                 };
    

    【讨论】:

      猜你喜欢
      • 2015-02-08
      • 2016-11-09
      • 2017-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多