Print Page | Close Window

EntityManager.DefaultManager

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=2585
Printed Date: 21-May-2026 at 12:08pm


Topic: EntityManager.DefaultManager
Posted By: danjal
Subject: EntityManager.DefaultManager
Date Posted: 25-Mar-2011 at 3:04am

Hi,

 

We upgraded our DevForce to 6.0.9 Silverlight.

With the new version we encounter a show stopper – EntityManager.DefaultManger is going to be obsolete.

 

We use a PivotViewer control in our application that use a collection that is generated server-side by some HttpHelpers. We have been discussing this before on this thread:

http://www.ideablade.com/forum/forum_posts.asp?TID=2525&KW=defaultmanager&PID=10054&title=entitymanager-server-side#10054 - http://www.ideablade.com/forum/forum_posts.asp?TID=2525&KW=defaultmanager&PID=10054&title=entitymanager-server-side#10054

 

When querying for data we use this code to get an EntityManager:

var m_entityManager = new C2NetDomainModelEntityManager(EntityManager.DefaultManager);

 

But this code does not work anymore.

 

What is the right way to use DevForce when working with a control like PivotViewer (dynamically generating a collection with HttpHelpers)?

 




Replies:
Posted By: DenisK
Date Posted: 28-Mar-2011 at 12:06pm
Hi danjal;

Could you elaborate on why you need to pass the DefaultManager to create another EntityManager?


Posted By: danjal
Date Posted: 29-Mar-2011 at 7:26am

Because we use a login manager, and it does not allow us to run this code:

 

var m_entityManager = new C2NetDomainModelEntityManager();

 

var query = new EntityQuery<EntImage>();

query.QueryStrategy = new QueryStrategy(FetchStrategy.DataSourceOnly, MergeStrategy.OverwriteChanges);

 

var images = m_entityManager.ExecuteQuery<EntImage>(query);

 

It worked before the upgrade, with help from the the DefaultManager.



Posted By: DenisK
Date Posted: 29-Mar-2011 at 5:56pm
Hi danjal;

I've read that previous thread and if I understand correctly, you want to handle a request that comes in using your custom HttpHandler.

Using smi-mark's sample, we can now do this inside the ProcessRequest method.

    public void ProcessRequest(HttpContext context) {
      context.Response.ContentType = "text/plain";
      context.Response.Write("Logged in as: ");
      context.Response.Write(context.User.Identity.Name);

     if (!AuthenticateUser(context.User)) {
        throw new Exception("No access!");
     }

     //Else you can query
      var mgr = new EntityManager();
      var query = new EntityQuery<Customer>();
      query.QueryStrategy = new QueryStrategy(FetchStrategy.DataSourceOnly, MergeStrategy.OverwriteChanges);
      try {
        var images = mgr.ExecuteQuery<Customer>(query);
        var count = images.Count();
      } catch (Exception e) {
        var msg = e.Message;
      }
    }



Posted By: danjal
Date Posted: 15-Apr-2011 at 4:20am

http://www.ideablade.com/forum/uploads/946/PivotWithLoginManager.zip - uploads/946/PivotWithLoginManager.zip

 
Hi,

 

I have made a little sample project where I try to get the logged in user thru the HttpContext – but it is empty .

 

I read the documentation from Ideablade on this issue, but I am missing something. Can someone look at the sample and help me?

 

1.       The sample application takes a username and password. These are passed into the LoginAsync method of the entitymanager. (MainPage.xaml.cs)

 

2.       These are then transferred to the Login method of a loginmanager that implements the IEntityLoginManager. (LoginManager.cs)

3.       The loginmanager validates the username and password against a database.

 

4.       When this process is done and successful, the user can load a collection to the pivotviewer. (ViewImageLibrary.xaml.cs)

 

5.       When doing this a http request is sent to the server where some httphelpers handle the request. (CxmlHandler.ProcessRequest in HttpHandlers.cs)

6.       The problem here is that the HttpContext.User is empty.

 

7.       Then the collection is created and sent back to the PivotViewer. (RNImageCollection.cs)

 

In my webconfig I have set these settings:

....

<serverSettings loginManagerRequired="true" />

....

<serverSettings useAspNetSecurityServices="true" />

....

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

....

<authentication mode="Forms" />

....

 

 



Posted By: smi-mark
Date Posted: 15-Apr-2011 at 6:03pm
Are you using asp.net authentication with DevForce? If so, the context sample should definitely work. I'll take a look at your sample project later, but it should work.


Posted By: danjal
Date Posted: 16-Apr-2011 at 3:22am

Hi smi-mark,

 

Do I have to do something special to use ASP.NET authentication with DevForce? A setting or something?

 

Thanks for helping.

                                                                           



Posted By: DenisK
Date Posted: 18-Apr-2011 at 12:39pm
Hi danjal;

I looked at your solution and it seems that you're using IEntityLoginManager. You have to use AspAuthenticatingLoginManager instead since you're using ASP.NET. 

http://drc.ideablade.com/ApiDocumentation/webframe.html?IdeaBlade.EntityModel.Web~IdeaBlade.EntityModel.Web.AspAuthenticatingLoginManager.html - http://drc.ideablade.com/ApiDocumentation/webframe.html?IdeaBlade.EntityModel.Web~IdeaBlade.EntityModel.Web.AspAuthenticatingLoginManager.html



Print Page | Close Window