在Linq to SQL中我有一个表达式返回一个int,并且我想根据返回一个布尔值的那个表达式创建一个表达式。 int可用于OrderBy(score)
,布尔值可用于Where(ifScore)
。我无法弄清楚如何使用分数来定义ifScore
,并希望得到一些帮助。在Int表达式中创建一个bool Linq to SQL表达式
Expression<Func<Model, int>> score = p =>
(testList.Count() > 0 && p.Name.Contains(testList.FirstOrDefault()) ? 1 : 0);
Expression<Func<Model, bool>> ifScore = p =>
//how to say if score > 2
你的第一个表达式只能返回1或0的整数,这基本上是一个真/假。不知道你在努力完成什么 – Aducci