different schema with same connection string

Posts   
 
    
tantj
User
Posts: 6
Joined: 29-Jul-2009
# Posted on: 12-Dec-2011 11:15:08   

I have the following scenario: one database with multi schema, then I create a .llblgenproj file for each schema, and they use a same connection string.

when I write a code like:


Test1.DataAccessAdapter adapter1 = new Test1.DataAccessAdapter();
Test2.DataAccessAdapter adapter2 = new Test2.DataAccessAdapter();

Test1.LinqMetaData metaData1 = new Test1.LinqMetaData(adapter1)
Test2.LinqMetaData metaData2 = new Test2.LinqMetaData(adapter2);

var query = (from table1 in metaData1.Table1
                    join table2 in metaData2.Table2
                    on table1.Id equals table2.Id
                    select new { table1.Id, table2.otherFilelds}).ToList();


it always show me

Requested value 'table2' was not found

,

Anyone have idea? Do I still need to put all schemas to the same .llblgenproj ?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-Dec-2011 04:40:58   

tantj wrote:

Anyone have idea? Do I still need to put all schemas to the same .llblgenproj ?

If you want to do joining between them, then Yes, you should put them together in the same project. You forgot to put the complete stack trace, but anyway the thing is that the provider that evaluates and executes the query is one, and when you do that join, the provider can't evaluate the projection because it doesn't know the existence of some tables/fields. So you should consider merge those schemas in one project or just separate those that don't are tightly related.

David Elizondo | LLBLGen Support Team
tantj
User
Posts: 6
Joined: 29-Jul-2009
# Posted on: 13-Dec-2011 07:01:37   

daelmo wrote:

tantj wrote:

Anyone have idea? Do I still need to put all schemas to the same .llblgenproj ?

If you want to do joining between them, then Yes, you should put them together in the same project. You forgot to put the complete stack trace, but anyway the thing is that the provider that evaluates and executes the query is one, and when you do that join, the provider can't evaluate the projection because it doesn't know the existence of some tables/fields. So you should consider merge those schemas in one project or just separate those that don't are tightly related.

here is the stacktrace stuck_out_tongue_winking_eye :


   at System.Enum.EnumResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument)
   at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult)
   at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
   at IFCA.Data.Common.FactoryClasses.ElementCreator.CreateDynamicRelation(String leftOperandEntityName, JoinHint joinType, String rightOperandEntityName, String aliasLeftOperand, String aliasRightOperand, IPredicate onClause) in D:\temp\ORM\Common\BusinessEntity\FactoryClasses\EntityFactories.cs:line 2687
   at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.CreateDynamicRelation(Object left, Object right, JoinHint joinType, String aliasLeft, String aliasRight, IPredicate onClause) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\ExpressionHandlers\QueryExpressionBuilder.cs:line 3308
   at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleJoinExpression(JoinExpression expressionToHandle) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\ExpressionHandlers\QueryExpressionBuilder.cs:line 2959
   at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleExpression(Expression expressionToHandle) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\ExpressionHandlers\GenericExpressionHandler.cs:line 180
   at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleExpression(Expression expressionToHandle) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\ExpressionHandlers\QueryExpressionBuilder.cs:line 141
   at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.HandleExpressionTree(Expression expression) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProProviderBase.cs:line 158
   at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProProviderBase.cs:line 92
   at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute(Expression expression) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProProviderBase.cs:line 697
   at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.Execute() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProQuery.cs:line 87
   at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProQuery.cs:line 162
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 13-Dec-2011 08:34:32   

I'm confused whether you have: - 1 Database i.e. 1 Catalog, but with 2 schemas (e.g. dbo.Northwind & Test.Northwind) - Or 2 different Catalogs in the same database Server.

tantj
User
Posts: 6
Joined: 29-Jul-2009
# Posted on: 13-Dec-2011 09:46:49   

Walaa wrote:

I'm confused whether you have: - 1 Database i.e. 1 Catalog, but with 2 schemas (e.g. dbo.Northwind & Test.Northwind) - Or 2 different Catalogs in the same database Server.

I have 1 database with several schema, and I create seperated .llblgenproj for each schema. Above namespace Test1 & Test2 is for making a distinction between different schemas ( one .llblgenproj generate the dlls with namespace Test1, the other generate the dlls with namespace Test2.

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 13-Dec-2011 10:32:36   

Each generated DAL is only aware of it's entities, and more importantly it's metadata (catalog name and schema name to use). So in your case you need to include both schemas in one llblgen project, and generate the code accordingly.

tantj
User
Posts: 6
Joined: 29-Jul-2009
# Posted on: 13-Dec-2011 11:49:31   

Walaa wrote:

Each generated DAL is only aware of it's entities, and more importantly it's metadata (catalog name and schema name to use). So in your case you need to include both schemas in one llblgen project, and generate the code accordingly.

yes, you are right, and I notice that entity framework can not be done with this. just a try, thank you guys.smile