I finally figured it out. That was hard, like pulling teeth.
IEntityQuery query = (IEntityQuery)PredicateBuilder.FilterQuery(Mgr.Members, aCompositePredicateDescription);
Mgr.ExecuteQueryAsync<Member>((IEntityQuery<Member>)query, (op) => { var results = op.Results; results.ForEach(Members.Add); } );
return Members;
|
I don't know if these changes get me any closer to the solution. The compile error is still the same statement but it doesn't like the ForEach statment as it doesn't belong to op.Results
IEntityQuery query = (IEntityQuery)PredicateBuilder.FilterQuery(Mgr.Members, aCompositePredicateDescription);
Mgr.ExecuteQueryAsync(query, op => op.Results.ForEach(Members.Add));
|
I am passing a query object to my GetMembers() method that holds a variable number of search parameters. After building the query with PredicateBuilder, I want to execute the query asynchronously and in the same method use lambda statements to fill the collection instead of using a callback operation. I am getting a compile error on the ExecuteAsynch method. How do I write this method correctly? It is the line in blue at the bottom of the method. public ObservableCollection<Member> GetMembers(MemberQO q) { List<PredicateDescription> predicateDescriptions = new List<PredicateDescription>();
PredicateDescription aPredicateDescription;
if (q.SSN != string.Empty) { aPredicateDescription = PredicateBuilder.Make(typeof(Member), "SocSecNo", FilterOperator.IsEqualTo, q.SSN); predicateDescriptions.Add(aPredicateDescription); }
if (q.LastName != string.Empty) predicateDescriptions.Add(PredicateBuilder.Make(typeof(Member), "LastName", FilterOperator.StartsWith, q.LastName));
if (q.FirstName != string.Empty) predicateDescriptions.Add(PredicateBuilder.Make(typeof(Member), "FirstName", FilterOperator.StartsWith, q.FirstName));
if (q.EmployeeNo != string.Empty) predicateDescriptions.Add(PredicateBuilder.Make(typeof(Member), "EmployeeNumber", FilterOperator.IsEqualTo, q.EmployeeNo));
if (q.CardNo != 0) predicateDescriptions.Add(PredicateBuilder.Make(typeof(Member), "CardNo", FilterOperator.IsEqualTo, q.CardNo));
if (q.Status != string.Empty) predicateDescriptions.Add(PredicateBuilder.Make(typeof(Member), "Status", FilterOperator.IsEqualTo, q.Status));
if (q.Office != string.Empty) predicateDescriptions.Add(PredicateBuilder.Make(typeof(Member), "Office", FilterOperator.IsEqualTo, q.Office)); CompositePredicateDescription aCompositePredicateDescription = PredicateBuilder.And(predicateDescriptions.ToArray());
var query = PredicateBuilder.FilterQuery(Mgr.Members, aCompositePredicateDescription);
query.ExecuteAsync<Member>(op => op.Results.ForEach(Members.Add)); return Members; }
|