Print Page | Close Window

Many Models per Manager

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=3405
Printed Date: 28-Apr-2024 at 7:18am


Topic: Many Models per Manager
Posted By: Vonzkie
Subject: Many Models per Manager
Date Posted: 25-Apr-2012 at 1:34am
Hi,

I've seen this topic and I find it cool:
http://drc.ideablade.com/xwiki/bin/view/Documentation/many-models-per-manager - http://drc.ideablade.com/xwiki/bin/view/Documentation/many-models-per-manager

Example, I have two Models:

Model A
Customer

Model B
Employee

Then using the approach given on the post, I'll use EntityManager to query:

so.. 

EntityManager context = new EntityManager();
var query1 = context.GetQuery<Customer>().Execute();
var query2 = context.GetQuery<Employee>().Execute();

the question would be, how about if Model A connects to DB A and Model B connects to DB B, how do we handle that?

Thanks,
Von



Replies:
Posted By: sbelini
Date Posted: 25-Apr-2012 at 3:28pm
Von,
 
There's no special handling if you want one EntityManager with multiple models from different datasources.
 
You simply create your models pointing to their respective datasources and in the model properties assign the mutual EntityManager name:
 
 
The only restriction is that you would not be able to have entities from different models, but with the same names. (i.e. Employee and Employee)
 
I'm attaching a simple solution showing one EM with multiple models from different datasources: uploads/892/T11806.zip - uploads/892/T11806.zip
 
Regards,
   Silvio.


Posted By: Vonzkie
Date Posted: 01-May-2012 at 10:56pm
Hi Silvio,

How about the IDataSourceKeyResolver, is it still possible here in different models?

Thanks,
Von



Print Page | Close Window