Print Page | Close Window

Executing a query server side in a svc

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=3702
Printed Date: 12-Jan-2026 at 12:31pm


Topic: Executing a query server side in a svc
Posted By: pponzano
Subject: Executing a query server side in a svc
Date Posted: 09-Oct-2012 at 6:55am
Hello,
I've got a svc service that I user for managing authentication stuff...when a User changes the password I should insert some data in 2 table...(I'm on the server side)

When I do


                my.DomainModel.Admin.TMRAdminEntities manager = new my.DomainModel.Admin.myAdminEntities();

//                manager = new DomainModel.Admin.MyAdminEntities(EntityManager.DefaultManager);

                var query = manager.aspnet_Users.Where(o1 => o1.UserName == username).Include("USER_ACCOUNT_EXPIRY");

I got :

EntityManager.DefaultManager is not available on the server because of threading and security concerns associated with static properties.

How can I use Ideablade on the server side?
Thanks



Replies:
Posted By: sbelini
Date Posted: 10-Oct-2012 at 10:11am
Hi Paolo,
 
The issue you are facing is due to the fact that the DefaultManager is static and should not be used across threads.
Also note that since you are using the EntityManager in a service you will need to log it in to perform queries. (i.e. unlike the EntityManager in the LoginManager, that is automatically logged in)
 
sbelini.


Posted By: pponzano
Date Posted: 10-Oct-2012 at 11:16pm
And so what should I use? there's no problem for me to login at the server side...
can you please provide me a sample?
 
Thanks


Posted By: sbelini
Date Posted: 11-Oct-2012 at 11:18am
You should not use the DefaultEntityManager.
I am slightly confused by your code as the reference to DefaultEntityManager is commented out, so I actually assumed that the line:
 
manager = new DomainModel.Admin.MyAdminEntities(EntityManager.DefaultManager);
is active in your app. (i.e. not commented out)
 



Print Page | Close Window