New Posts New Posts RSS Feed: WCF and Idealblade
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

WCF and Idealblade

 Post Reply Post Reply
Author
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Topic: WCF and Idealblade
    Posted: 21-Feb-2012 at 12:18pm
Hi hartdrooz,
 
Since your EntityManager was created in the first request, you wouldn't have a problem there because it was created and used in the same thread. For every subsequent request, most likely it will run a different thread and then the error you are getting.
If you are certain that there won't be more than 1 client connection at the same time, you could simply set
 
managerAuthorizeThreadId = null;
 
However, if there is more than one client request concurrently that uses the same EntityManager, you might face some unwanted behavior. In this case your best option is to set a new EntityManager for each request. (However, since your service is by session, you wouldn't run into this)
 
Regards,
   Silvio.


Edited by sbelini - 21-Feb-2012 at 1:04pm
Back to Top
hartdrooz View Drop Down
Newbie
Newbie


Joined: 09-Feb-2012
Posts: 2
Post Options Post Options   Quote hartdrooz Quote  Post ReplyReply Direct Link To This Post Posted: 17-Feb-2012 at 11:31am
Hi,

I created a WCF service, in this service I use idealblade to retrieve the data and send the entities to the client.

I have a class, this class have a constructor and in this constructor I create an instance of my entityManager (this is inside a private variable of the class).

After that the other methods use this private variable to do my queries.

The WCF service is by session so when the session is closed I do a disconnect to my private variable and I put it null.

So I open my client first time I retrieve data from a table it works without any problem.

I close my client, I open it again I do the same call and I got an error than I cannot run the query in this thread because it's use by another thread .....

I don't understand why ?

So I remove the private variable and create a variable inside each methods that do a call to the database in the WCF service and I don't have this error anymore.

But is not really a good pratice, I want to have a private variable inside the class and I was expecting no problem of threading because the client is closed etc...

Regards
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down