Hi all,
I am fairly new to CSLA and am not sure where to look to see what is causing the following error but believe it's something simple that some of you CSLA guru's could tell me fairly quickly :-)
Unable to cast object of type 'Csla.Data.ContextManager`1[DalLinq.Parts.PartsDataContext]' to type 'Csla.Data.ContextManager`1[DalLinq.Core.CoreDataContext]'.
I have set up multiple DataContexts, two of which are PartsDataContext and CoreDataContext. I get the error above when I am using PartsDataContext and try to call a business object that uses CoreDataContext. The code I'm using to setup the DataContexts is as follows:
using (var ctx = ContextManager<DalLinq.Core.CoreDataContext>.GetManager(DalLinq.Database.MyDb))
using (var ctx = ContextManager<DalLinq.Parts.PartsDataContext>.GetManager(DalLinq.Database.MyDb))
Does anyone know what is causing this problem? As I look back at what I've written, would it be anything to do with both Context's pointing at the same database?
Thanks,
Colm
Cheers Andy.
I've changed the code to use a different string name but am still getting the same problem. Looking at how ContextManager is implemented, it seems that the ContextManager uses the database connection string as the key rather than what this string is called in the application settings which means that you can only use one datacontext concurrently that points to the same database. I suppose this is in an effort to contain one open connection to the database, most likely to avoid MS DTC kicking in?
Cheers Andy,
No, I'm not using the overload.
I'm refactoring to use only one ConextManager/dbml as that seems to be the way it's supposed to be done. Don't want the performance hit of DTC either.
Thanks for your replies,
Colm
Copyright (c) Marimer LLC