| Author |
Share Topic Topic Search Topic Options
|
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Topic: How add a custom method to entitymanager class ? Posted: 12-Jun-2010 at 7:06am |
|
Use EntityManager.InvokeServerMethodAsync(). See the documentation on Remote Service Methods.
|
 |
ehsan
Newbie
Joined: 02-Jun-2010
Posts: 15
|
Post Options
Quote Reply
Posted: 11-Jun-2010 at 10:25pm |
|
I exactly want to retreive from database, but not using default operations of entitymanager or using linq to devforce queries, but by calling some async server methods. How can i do it ?
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 10-Jun-2010 at 4:23pm |
|
The EntityManager is operating client-side. You can do all of the synchronous client-side stuff you want to. If you have to retrieve data from the backend database, that's a different story.
|
 |
ehsan
Newbie
Joined: 02-Jun-2010
Posts: 15
|
Post Options
Quote Reply
Posted: 08-Jun-2010 at 8:36pm |
I shared my partial class as linked file in client project & now I can call methods, but synchronously ! I've heared that silverlight does not supports synchronous calls, but I can call them synchronously !!!
Assume that my method does a time-consuming operation & returns a serializable data type, how can I define an asynchronous operation here ?
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 08-Jun-2010 at 5:41pm |
|
As I said before, you'll need to add the file with the partial EM class as a shared file in your client project in order to have access to the method - just as the TestTableModel.IB.Designer.cs file is linked as a shared file.
As for "calling it asynchronously": what exactly do you want this method to do and/or return?
|
 |
ehsan
Newbie
Joined: 02-Jun-2010
Posts: 15
|
Post Options
Quote Reply
Posted: 07-Jun-2010 at 11:13pm |
I've a file which has created by EntityFramework wizard & modified by devforce, it name is : TestTableModel.IB.Designer.cs
It contains :
...
namespace DevForceSilverlightApplication {
/// <summary>
/// The domain-specific EntityManager for your domain model.
/// </summary>
[IbEm. DataSourceKeyName(@"TestEntities")]
public partial class TestEntities : IbEm.EntityManager {
...
}
}
now I want to add some methods to TestEntities class (for example doTest method), I created a partical class in a new file & named id TestEntities.cs :
namespace DevForceSilverlightApplication {
public partial class TestEntities /*: IbEm.EntityManager*/{
public void doTest() { ... }
}
}
I think this problem is a little more complicated than just adding a partial class & defining methods.
In wcf there is an [OperationContract] directive which identifies this method is a service operation, or in RIA there is an [EnableClientAcceess] directive which identifies client can see this class.
but here how can i access doTest method from client entitymanager object & call it asynchronously in silverlight ?
Edited by ehsan - 08-Jun-2010 at 2:41am
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 07-Jun-2010 at 2:19pm |
Did you define your partial class file in the web project and then
forget to share it on the client? That would explain this:
Originally posted by ehsan
I tried to define them is a partial class but in this state I cant access them from client... |
|
 |
ehsan
Newbie
Joined: 02-Jun-2010
Posts: 15
|
Post Options
Quote Reply
Posted: 07-Jun-2010 at 1:15am |
I want to ad some custome methods to entity manager in my domain model . I need call those methods directly using silverlight, so they must be async .
how can i do this & where is the best place for defining such methods ? ( I tried to define them is a partial class but in this state I cant access them from client, when i define them in the main class, Client can see them, but when call them nothing happens. I know I should define them in a manner that I can call them asynchronously, but i dont know how :(( )
Edited by ehsan - 07-Jun-2010 at 1:23am
|
 |