问题描述:

I have a method that creates a predicate based on the data from several fields. The fields can contain comma separated values. I can create a predicate that will OR the values in the field but then I need to AND the fields together.

 if (model.MICA != null)

{

List<string> ids = ParseCSVList(model.MICA);

foreach (var id in ids)

{

predicate = predicate.Or(m => m.idtype == "MICA" && m.idnumber.Contains(id));

}

}

** I need to AND these two records together**

if (model.FRID != null)

{

List<string> ids = ParseCSVList(model.FRID);

foreach (var id in ids)

{

predicate = predicate.Or(e => e.idtype == "FRID" && e.idnumber.Contains(id));

}

}

When building a predicate is there an easy way to do that?

网友答案:

What's wrong with using predicate.And?

相关阅读:
Top