Print Page | Close Window

Generated EntityManager on the server

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=4102
Printed Date: 19-Sep-2025 at 6:26pm


Topic: Generated EntityManager on the server
Posted By: stephenmcd1
Subject: Generated EntityManager on the server
Date Posted: 09-Apr-2013 at 11:13am
We currently have a bunch of custom code (helper methods, etc.) in our custom sub-class of EntityManager - and that is in addition to all the code that the standard T4s generate (for building entity queries and stored procedure queries).  The trouble comes when we are on the Web Server during a query or save.  In that case, all the Entity Managers are just the 'vanilla' EntityManager class so we end up with a lot of code that needs to behave slightly differently on the server than it does on the client.  It's not terrible but the friction is starting to add up and I think we need to do something about it.

I'm looking at moving all the logic that is currently in our EntityManager sub-class into a separate standalone class that can 'wrap' any EntityManager and provide the same query building, etc. logic.  With some simple tweaks in the T4s, this doesn't look to hard.  However, I first wanted to ask if you would consider making this the default behavior (or perhaps some sort of configuration / opt-in behavior)?  It seems like this would be a good feature in general if the EntityManagers on the sever could be the custom typed version.

But if it doesn't seem like that will happen, I'll go ahead with my standalone helper class idea.

Thanks,
-Stephen



Replies:
Posted By: kimj
Date Posted: 10-Apr-2013 at 8:41am
Hi Stephen,

This isn't something we plan to address in the near term, so you're better off going with your idea.

Although most applications do have only a single sub-typed EntityManager, a fair number have multiple models, so we'd need some sort of factory method we could call on the server to obtain an EM or the type of the EM. Or we could do as we do with RPC methods and pass the EM type with the message. At any rate, although a bit of a pain, it's still usually easy enough to use the EM copy constructor, an extensions class, or a wrapper class to work with the EntityManager.


Posted By: stephenmcd1
Date Posted: 10-Apr-2013 at 9:49am
Thanks for the update.  I'll continue on with my own way.  

On a side note, I just noticed that custom logic you do with RPC calls to create the correct type of EM.  I had never noticed that before because we always have code that tries to support a custom sub-type as well as a plain one.  That could be nice to do that kind of thing for queries and saves....but I understand it's probably one of the more obscure feature requests I've come up with so I won't bother.

Thanks!



Print Page | Close Window