I know how to use Predicate Descriptions with Ands.
I have the following code
public IEnumerable<MembersAndJobHistory> GetMembersForBatchByEmployer(Batch batch)
{
IPredicateDescription compositePred;
PredicateDescription p1 = null, p2 = null, p3 = null, p4 = null, p5 = null, p6 = null;
p1 = PredicateBuilder.Make(typeof(MembersAndJobHistory), "Status", FilterOperator.IsEqualTo, "A");
p2 = PredicateBuilder.Make(typeof (MembersAndJobHistory), "EmployerNo", FilterOperator.IsEqualTo,
batch.EmployerNo);
p3 = PredicateBuilder.Make(typeof(MembersAndJobHistory), "PayVia", FilterOperator.IsEqualTo, "E");
if (!CommonControl.IsControlTrue("NoMonthlyDues"))
{
p4 = PredicateBuilder.Make(typeof(MembersAndJobHistory), "Dues", FilterOperator.IsEqualTo, 0);
}
if (batch.BillYN != null)
{
p5 = PredicateBuilder.Make(typeof(MembersAndJobHistory), "BillYN", FilterOperator.IsEqualTo, batch.BillYN);
}
p6 = PredicateBuilder.Make(typeof(MembersAndJobHistory), "TSStart", FilterOperator.IsLessThanOrEqualTo, batch.PayPeriodEnd);
compositePred = CombinePreds(p1, p2, p3, p4, p5, p6);
var query = Manager.MembersAndJobHistories
.Where(compositePred)
.OrderBy(m => m.SocSecNo);
var results = query.Execute();
return results;
}
public IPredicateDescription CombinePreds(params PredicateDescription[] preds)
{
var nonNullPreds = preds.Where(pd => pd != null).ToArray();
var result = PredicateBuilder.And(nonNullPreds);
return result;
}
Now i need to add two more predicates to the query. Basically i want to And an Or. For example, and where
TSFinish >= batch.PayPeriod or TSFinish is null
How do i fix my code to handle these 2 new predicates?
Bill