thanks to Jay from IdeaBlade, I have a solution to my problem which i wish to share in case others come across this same situation.
This code allows me to pass a Query Object to my Repository GetMembers() method and then build a predicateDescription for each property of the QueryObject that is not null. i then pass the PredicateDescription objects to the CombinePreds as an arrary and the CombinePreds picks out the non nulls ones and combines them. It then passes the combined one back to my Get method which then is used in the .Where clause of the query.
Thans again to Jay for your help. As I have always said IdeaBlade has a great support team for the customers.
public IPredicateDescription CombinePreds(params PredicateDescription[] preds)
{
var nonNullPreds = preds.Where(pd => pd != null).ToArray();
var result = PredicateBuilder.And(nonNullPreds);
return result;
}
public IEnumerable<MembersList> GetMembers(MemberQO memberQO)
{
IPredicateDescription compositePred;
PredicateDescription p1 = null, p2 = null, p3 = null, p4 = null, p5 = null, p6 = null;
if (memberQO.SocSecNo != null)
{
p1 = PredicateBuilder.Make(typeof (MembersList), "SocSecNo", FilterOperator.IsEqualTo, memberQO.SocSecNo);
}
if (memberQO.CardNo != null)
{
p2 = PredicateBuilder.Make(typeof (MembersList), "CardNo", FilterOperator.IsEqualTo,
memberQO.CardNo);
}
if (memberQO.EmployeeNo != null)
{
p3 = PredicateBuilder.Make(typeof(MembersList), "EmployeeNumber", FilterOperator.IsEqualTo,
memberQO.EmployeeNo);
}
if (memberQO.LastName != null)
{
p3 = PredicateBuilder.Make(typeof (MembersList), "LastName", FilterOperator.StartsWith,
memberQO.LastName);
}
if (memberQO.FirstName != null)
{
p4 = PredicateBuilder.Make(typeof(MembersList), "FirstName", FilterOperator.StartsWith,
memberQO.FirstName);
}
if (memberQO.Office != null)
{
p5 = PredicateBuilder.Make(typeof(MembersList), "Office", FilterOperator.IsEqualTo,
memberQO.Office);
}
if (memberQO.Status != null)
{
p6 = PredicateBuilder.Make(typeof(MembersList), "Status", FilterOperator.IsEqualTo,
memberQO.Status);
}
compositePred = CombinePreds(p1, p2, p3, p4, p5, p6);
var query = Manager.MembersLists
.Where(compositePred)
.OrderBy(m => m.SocSecNo);
var results = query.Execute();
return results;
}