runtime change catalog

Posts   
 
    
yuewahchan
User
Posts: 7
Joined: 03-Apr-2008
# Posted on: 03-Apr-2008 10:23:55   

if i have 2 catalogs , e.g. basedb, corpdb1 , can I change one of the catalog i.e. corpdb1 -> corpdb2 in runtime, provided that corpdb1 and corpdb2 have the same database schema!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-Apr-2008 10:45:55   

Yes you can. Please check the manual's section Catalog name overwriting, under "Using the generated code -> Application configuration through .config files"

yuewahchan
User
Posts: 7
Joined: 03-Apr-2008
# Posted on: 03-Apr-2008 10:59:47   

by the way, I can overwrite the catalog name. However there is problem when fetching the related entity in different database

In the database schema, there are 3 tables: basedb..Employee corpdb1..Order corpdb2..Order

In the llblgen catalog, there are 2 catalogs: basedb and corpdb

And, there is relationship between column [corpdb.Order.EmplNo] and basedb.Employee.EmplNo]

then I overwrite the catalog from corpdb -> corpdb2 in runtime and then fetch the corpdb.Order <= it works and then fetch the corpdb.Order.Employee <= it throws exception

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-Apr-2008 11:08:01   

Would you please post the exception and stack trace?

yuewahchan
User
Posts: 7
Joined: 03-Apr-2008
# Posted on: 03-Apr-2008 11:28:23   

corpdb..Order = corpdb..applanh basedb..Employee = basedb..CorpEmpl

A first chance exception of type 'SD.LLBLGen.Pro.ORMSupportClasses.ORMEntityOutOfSyncException' occurred in SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll
System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>ConsoleApplication1.vshost.exe</AppDomain><Exception><ExceptionType>SD.LLBLGen.Pro.ORMSupportClasses.ORMEntityOutOfSyncException, SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=2.5.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27</ExceptionType><Message>The entity is out of sync with its data in the database. Refetch this entity before using this in-memory instance.</Message><StackTrace>   at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.GetValue(Int32 fieldIndex, Boolean returnDefaultIfNull)
   at iTurbo.EntityClasses.ApplanHEntity.get_NvrRecEmplNo() in c:\documents and settings\administrator\my documents\llblgen pro projects\databasegeneric\entityclasses\applanhentity.cs:line 820
   at iTurbo.EntityClasses.ApplanHEntity.GetRelationInfoCorpEmpl() in c:\documents and settings\administrator\my documents\llblgen pro projects\databasegeneric\entityclasses\applanhentity.cs:line 336
   at ConsoleApplication1.Program.Main(String[] args) in C:\Documents and Settings\Administrator\My Documents\ConsoleApplication1\Program.cs:line 49
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>SD.LLBLGen.Pro.ORMSupportClasses.ORMEntityOutOfSyncException: The entity is out of sync with its data in the database. Refetch this entity before using this in-memory instance.
   at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.GetValue(Int32 fieldIndex, Boolean returnDefaultIfNull)
   at iTurbo.EntityClasses.ApplanHEntity.get_NvrRecEmplNo() in c:\documents and settings\administrator\my documents\llblgen pro projects\databasegeneric\entityclasses\applanhentity.cs:line 820
   at iTurbo.EntityClasses.ApplanHEntity.GetRelationInfoCorpEmpl() in c:\documents and settings\administrator\my documents\llblgen pro projects\databasegeneric\entityclasses\applanhentity.cs:line 336
   at ConsoleApplication1.Program.Main(String[] args) in C:\Documents and Settings\Administrator\My Documents\ConsoleApplication1\Program.cs:line 49
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()</ExceptionString></Exception></TraceRecord>
Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-Apr-2008 12:01:51   

This seems not related to Catalog name overwrites.

Would you please post the corresponding code snippet? And the generated SQL Query if any? (check the manual "Using the generated code -> Troubleshooting and debugging")

yuewahchan
User
Posts: 7
Joined: 03-Apr-2008
# Posted on: 03-Apr-2008 12:09:45   

if do not apply catalog overwrite, everything is ok, anyway I prepare the info that u need , thank you !

yuewahchan
User
Posts: 7
Joined: 03-Apr-2008
# Posted on: 03-Apr-2008 12:33:32   

oh....it work when using DataAccessAdapter + prefetchPath

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-Apr-2008 12:45:59   

Shall I consider the issue solved?