Print Page | Close Window

POCO Problem

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1366
Printed Date: 13-Mar-2025 at 4:15am


Topic: POCO Problem
Posted By: pharry
Subject: POCO Problem
Date Posted: 08-Jul-2009 at 4:19am
Hi,
I am trying to extend the POCO sample by adding a User class to the example.
 
I am getting the following error when making the executeasync call.
 
I have tried this:

_mgr.ExecuteQueryAsync<User>(_mgr.Users(), GotUsers, null);

and this:
 
var rq = new EntityQuery<User>("Users", _mgr);

rq.ExecuteAsync(GotUsers, null);

 
TIA
 
Error 19 'IdeaBlade.EntityModel.EntityQuery<AppWithPocos.Pocos.User>' does not contain a definition for 'ExecuteAsync' and the best extension method overload 'IdeaBlade.EntityModel.EntityQueryExtensions.ExecuteAsync<T>(IdeaBlade.EntityModel.IEntityQuery<T>, IdeaBlade.EntityModel.AsyncCompletedCallback<IdeaBlade.EntityModel.EntityFetchedEventArgs<T>>, object)' has some invalid arguments C:\Dev\Pocos\AppWithPocos\MainPage.xaml.cs 62 9 AppWithPocos
Error 20 Argument '2': cannot convert from 'method group' to 'IdeaBlade.EntityModel.AsyncCompletedCallback<IdeaBlade.EntityModel.EntityFetchedEventArgs<AppWithPocos.Pocos.User>>' C:\Dev\Pocos\AppWithPocos\MainPage.xaml.cs 62 25 AppWithPocos



Replies:
Posted By: kimj
Date Posted: 10-Jul-2009 at 5:59pm
My guess is that the GotUsers method has the wrong signature.  To keep the compiler happy it should be:
   private void GotUsers(EntityFetchedEventArgs<User> args)
 
In case that's not it, here's a review of other things to look at:
 
1) The User class should be "shared" between the AppWithPocos and AppWithPocosWeb projects, just like the State class is in States.cs.
 
2) Make sure that the User class is "known" to DevForce.  There are several ways to do this, one is to have the class implement the marker interface IdeaBlade.EntityModel.IKnownType.
 
3) Define a GetUsers method in a service provider class.  The easiest place to do this is within the PocoServiceProvider class in the sample.  The method should return an IEnumerable<User>.
 
4) Since you tried a Users() extension method, it should be defined like so:
      public static EntityQuery<User> Users(this EntityManager em) {
         return new EntityQuery<User>("Users", em);
      }
5) The callback defined in the ExecuteQueryAsync or ExecuteAsync call should have the correct signature (as shown above).
 
 
 


Posted By: pharry
Date Posted: 12-Jul-2009 at 8:00pm
Hi Kim,
 
Thanks for the reply. After checking your suggestions I found I was returning  IEnumerable<State> rather than IEnumerable<User> in my GetUses procedure, you need to be careful when copying code :-).



Print Page | Close Window