【问题标题】:How to use IN Operator inside Where Condition in Linq如何在 Linq 的 Where 条件中使用 IN 运算符
【发布时间】:2016-05-03 15:25:57
【问题描述】:

我需要关于如何在 linq 中使用 IN 运算符的帮助,

这是我的代码:

  achieved =grouped.Key.SMCode=="HETAL1"? 
 grouped.AsEnumerable().Where(x => (x.SalesManCode=="HETAL1"||x.SalesManCode=="BAIJU") &&
 x.OrderType == "Sales Invoice" && x.IsFromService==true).Sum(m => m.OrderValue):0

这里我需要 Salesmancode baijuhetal1 的值,但现在我只得到 hetal1 的值

我不知道,如何在 linq 中使用 IN 运算符

请帮我获取两个salesmancode的值

【问题讨论】:

    标签: entity-framework linq linq-to-sql linq-to-entities


    【解决方案1】:

    请尝试如下图。

     achieved =(grouped.Key.SMCode=="HETAL1" || grouped.Key.SMCode=="BAIJU") ? 
     grouped.AsEnumerable().Where(x => (x.SalesManCode=="HETAL1"||x.SalesManCode=="BAIJU") &&
     x.OrderType == "Sales Invoice" && x.IsFromService==true).Sum(m => m.OrderValue):0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-15
      • 1970-01-01
      • 1970-01-01
      • 2017-02-02
      • 1970-01-01
      • 2020-11-01
      • 1970-01-01
      相关资源
      最近更新 更多