New Posts New Posts RSS Feed: Many models per manager : Get query for an entity in both model.
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Many models per manager : Get query for an entity in both model.

 Post Reply Post Reply
Author
nazbrok View Drop Down
Newbie
Newbie
Avatar

Joined: 26-Jan-2011
Location: Paris
Posts: 21
Post Options Post Options   Quote nazbrok Quote  Post ReplyReply Direct Link To This Post Topic: Many models per manager : Get query for an entity in both model.
    Posted: 03-Aug-2011 at 6:55am
Hi,


what happen if I have the same entity, let's name it Customers, in both model (but incomplet in one of them)
I will get Entities from witch model this syntax ?
 
 manager = new EntityManager();
var query = new EntityQuery<Customer>("Customers", manager);
query.ExecuteAsync();

Is it possible to spécify the model/source to use ? 


Back to Top
robertg View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Mar-2011
Location: California
Posts: 87
Post Options Post Options   Quote robertg Quote  Post ReplyReply Direct Link To This Post Posted: 05-Aug-2011 at 2:15pm

Nazbrok,

In order to make this work properly, you need to sanitize the names of your classes, or to at least keep them segregated. There are two techniques for this; which one you use is up to you.
 
I'm attaching a very simple Silverlight project that demonstrates both of these techniques.
 
In the first technique, you'll edit your EDMX or EDMXs via the GUI, so that each of your classes has a unique name. In my case, I had the class "Customer" in both model1 and model2. I fixed the conflict by changing the name of the model in the GUI to Model2Customer, then saving the file. My designer file (which includes the generated classes) was recreated, and honored this new class name. Thus, I was able to access the class Customer (from my first edmx) and Model2Customer (from the second) seperately.
 
In the second technique, you wouldn't edit your EDMX files, but you'd give one or more models their own namespace, so the classes within them don't conflict. In my case, I changed the namespace for Model3 from the project default of "MultipleModels" to Model3Namespace, then accessed its version of "Customer" as Model3Namespace.Customer. (You do this by going to properties for the custom tool associated with this model, Model3.edmx.tt, and adding the new namespace to the property "Custom Tool Namespace". When you save those changes, your designer file is recreated.)
 
 
Yours,
Robert
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down