Compile error on ExecuteAsynch method
Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2264
Printed Date: 23-Jan-2026 at 9:55pm
Topic: Compile error on ExecuteAsynch method
Posted By: BillG
Subject: Compile error on ExecuteAsynch method
Date Posted: 26-Oct-2010 at 2:07pm
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; }
|
Replies:
Posted By: BillG
Date Posted: 26-Oct-2010 at 2:25pm
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));
|
Posted By: BillG
Date Posted: 26-Oct-2010 at 3:31pm
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;
|
|