Views: 15.5K
Replies: 3
Archived
|
Patterns In Action 4 - DataObjectFactoryHi,
In the DataObjectFactory class there is the CreateContext static method that is used to create the context for the ActionEntities. If I'm using multiple models in my project and want to create those contexts similarly, how would I update the DataObjectFactory to work in this fashion? What's the best way to go about achieving this? I could create separate CreateContext methods for each set of entities, but it doesn't seem right (CreateActionContext(), CreateAccountContext(), etc...). Any suggestions? Thanks. Doug Doug Rohm, Nov 28, 2010
|
|
Reply 1Doug:
The DataObjectFactory caches the connectionstring so that the context can be created quickly. So, the DataObjectFactory represents a database connection, which would suggest that if your EF Models reside in the same database your above suggestions is appropriate (i.e. CreateActionContext, CreateAccountContext, etc). However, if your EF Models reside in different databases, then you will want to create additional DataObjectFactory classes, one for each database connection. Hope this helps. Dan McMillan, Dec 12, 2010
|
|
Reply 2Hi Dan,
I replied to your question above. Hopefully that clears up what I'm trying to do. If not, let me know. Doug Doug Rohm, Dec 06, 2010
|
|
Reply 3Doug:
What do you mean with mulitple models? Multiple databases, classes, or modules (groups of classes)? Dan. Dan McMillan, Dec 03, 2010
|