【问题标题】:Linq Expression treeLinq 表达式树
【发布时间】:2015-07-03 08:40:41
【问题描述】:

我想生成像这样的表达式树

StatusRAG.where(x=> (overallRAG.Contains(x.OverallRAG) == overallRAGinclusive) || (costRAG.Contains(x.CostRAG) == costRAGinclusive))

这是我的数据:

var overallRAG  = new  List<string>(){"Red", "Green"}
var costRAG  = new  List<string>(){"Red", "Amber"}
bool overallRAGinclusive = true
bool costRAGinclusive = false
class StatusRAG
{
    public OverallRAG {get; set;}
    public CostRAG {get; set;}
}

【问题讨论】:

  • 你有什么问题?
  • 我想应用动态过滤器。用户可以从 UI 中选择整体 RAG 值(红色、绿色、琥珀色),并且可能希望包含或排除这些数据。用户可以对两个 RAG 应用过滤器或仅对 1 个应用过滤器。

标签: linq expression-trees


【解决方案1】:

Linq 表达式错误。我认为你不需要等于 costrag。

StatusRAG.where (x=> overallRAG.Contains(x.OverallRAG) || !costRAG.Contains(x.CostRAG))

【讨论】:

  • 不,我只是想生成动态表达式,例如:StatusRAG.where (x=>overallRAG.Contains(x.OverallRAG))
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-17
  • 2012-02-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-28
相关资源
最近更新 更多