我有以下代码......
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)是一个字符串。我想使用IEnumerable的centreNumbers。我试过以下......
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参数上过滤examinerTemp.CentreRegionMaps.CentreNumber。
非常感谢您的任何帮助。
答案 0 :(得分: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)
)
);