2

我有以下代码...

examinerSpec.Predicate = examinerSpec.AndExpression(examinerSpec.Predicate,
     centreTemp =>centreTemp.ExaminerCentreAssociations.Any(
     examinerTemp =>examinerTemp.CentreRegionMaps.CentreNumber.
     Contains(**currentCentreNumber**) &&
     examinerTemp.CentreRegionMaps.Active == true &&
     examinerTemp.DateStart <= DateTime.Now &&
     (!examinerTemp.DateEnd.HasValue ||
     examinerTemp.DateEnd.Value >= DateTime.Now)));

Contains(currentCentreNumber) 中的 CurrentCentreNumber 是一个字符串。我想使用 centerNumbers 的 IEnumerable。我尝试了以下...

examinerSpec.Predicate = examinerSpec.AndExpression(examinerSpec.Predicate,
   centreTemp =>
   centreTemp.ExaminerCentreAssociations.Any(
   examinerTemp =>
   examinerTemp.CentreRegionMaps.CentreNumber.
   Any(currentCentreNumber) &&
   examinerTemp.CentreRegionMaps.Active == true &&
   examinerTemp.DateStart <= DateTime.Now &&
   (!examinerTemp.DateEnd.HasValue ||
   examinerTemp.DateEnd.Value >= DateTime.Now)));

那是行不通的。编译器告诉我“无法推断该方法的类型参数”。

我真的需要在 IEnumerable 参数上过滤 ExamerTemp.CentreRegionMaps.CentreNumber。

非常感谢您的帮助。

4

1 回答 1

0

这行得通吗?很难推断你的类型......

examinerSpec.Predicate = examinerSpec.AndExpression
    (examinerSpec.Predicate,
        centreTemp =>
            centreTemp.ExaminerCentreAssociations.Any(examinerTemp =>
                examinerTemp.CentreRegionMaps.CentreNumber.Any(cn => cn == currentCentreNumber) &&
                examinerTemp.CentreRegionMaps.Active == true &&
                examinerTemp.DateStart <= DateTime.Now &&
                (!examinerTemp.DateEnd.HasValue || examinerTemp.DateEnd.Value >= DateTime.Now)
            )
    );
于 2013-04-10T15:23:00.027 回答