filtering on related entity's subtype

Posts   
 
    
wtijsma
User
Posts: 252
Joined: 18-Apr-2006
# Posted on: 25-Aug-2008 17:39:17   

Hi,

I'm looking for a way to filter on the type of a 1-N related entity property.

The situation is:

  • DoelpakketElementEntity has a 1-N relation with ElementEntity, with a property 'Element' mapped it
  • ElementEntity has a inherited entity named ActiviteitEntity

Most intuitive would be to do something like this:


linqMetaData.DoelpakketElement.Where(x=>x.Element is ActiviteitEntity)

or


linqMetaData.DoelpakketElement.Where(x=>(x.Element as ActiviteitEntity)!=null)

However both calls seem to fail. Any alternative approaches?

Using: Adapter templates, SQL 2005 DQE, LLBLGen runtime libraries of the 21th of August.

Output for the first example is:


: Initial expression to process:
value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource2`1[CC.ECDGenie.Dal.EntityClasses.DoelpakketElementEntity]).Where(pt => (pt.Element Is ActiviteitEntity))
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query: 
    Query: SELECT [LPLA_1].[id] AS [Id], [LPLA_1].[creator_account_id] AS [CreatorAccountId], [LPLA_1].[versie_startdatum] AS [VersieStartdatum], [LPLA_1].[versie_einddatum] AS [VersieEinddatum], [LPLA_1].[versie_nummer] AS [VersieNummer], [LPLA_1].[versie_object_id] AS [VersieObjectId], [LPLA_1].[parent_doelpakket_element_id] AS [ParentDoelpakketElementId], [LPLA_1].[duur_keer] AS [DuurKeer], [LPLA_1].[ordinal] AS [Ordinal], [LPLA_1].[doelpakket_id] AS [DoelpakketId], [LPLA_1].[element_id] AS [ElementId] FROM [dbo].[tb_ECDGenie_DoelpakketElement] [LPLA_1] (nolock) WHERE ( ( ( ( ( [LPLA_2].[id] IS NOT NULL)))))

Method Exit: CreateSelectDQ
Method Exit: CreatePagingSelectDQ: no paging.
TestCase 'CC.ECDGenie.Dal.UnitTests.LlblgenTests.LlblgenSelectBasedOnSubtype'
failed: SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: The multi-part identifier "LPLA_2.id" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
    SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: The multi-part identifier "LPLA_2.id" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception. ---> System.Data.SqlClient.SqlException: The multi-part identifier "LPLA_2.id" could not be bound.
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
    at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
    at System.Data.SqlClient.SqlDataReader.get_MetaData()
    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
    at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
    at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
       --- End of inner exception stack trace ---
    at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, IEntityFactory2 entityFactory, IEntityCollection2 collectionToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo, Boolean allowDuplicates, IEntityFields2 fieldsUsedForQuery)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollectionInternal(IEntityCollection2 collectionToFill, IRelationPredicateBucket& filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection(IEntityCollection2 collectionToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath2 prefetchPath, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider2.ExecuteEntityProjection(QueryExpression toExecute)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute(Expression expression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.Execute()
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
    D:\Projects\dotNet\Net3.5\CC.ECDGenie\MainLine\Dal\CC.ECDGenie.Dal.UnitTests\LlblgenTests.cs(116,0): at CC.ECDGenie.Dal.UnitTests.LlblgenTests.LlblgenSelectBasedOnSubtype()

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 25-Aug-2008 18:08:27   

Strange. We have a couple of unittests using that construct without a problem. I'll look into it.

(edit) Reproduced:


        [Test]
        public void GetAllBoardMembers()
        {
            using(DataAccessAdapter adapter = new DataAccessAdapter())
            {
                LinqMetaData metaData = new LinqMetaData(adapter);
                var q = metaData.Employee.Where(e => e.WorksForDepartment is MarketingEntity);

                int count = 0;
                foreach(var v in q)
                {
                    count++;
                }
                Assert.AreEqual(1, count);
            }
        }

fails. The tests we had were focussing on the entity from the source, not the related entity. the routine handling the 'is' and 'as' keywords doesn't take that into account. Will look into it.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 26-Aug-2008 12:38:41   

It appears the related entity's tables are never joined with the set, the relation isn't propagated.

(Edit) fixed in next build. (both approaches work now, same routine which made the mistake)

Frans Bouma | Lead developer LLBLGen Pro
wtijsma
User
Posts: 252
Joined: 18-Apr-2006
# Posted on: 26-Aug-2008 12:58:00   

Otis wrote:

It appears the related entity's tables are never joined with the set, the relation isn't propagated.

(Edit) fixed in next build.

Great!

Thanks for the quick solution as always simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 26-Aug-2008 12:58:46   

wtijsma wrote:

Otis wrote:

It appears the related entity's tables are never joined with the set, the relation isn't propagated.

(Edit) fixed in next build.

Great!

Thanks for the quick solution as always simple_smile

I'll fix the other issue you reported yesterday and then attach a new build to that thread.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 26-Aug-2008 13:33:40   

The fixed linq provider is attached.

Frans Bouma | Lead developer LLBLGen Pro
wtijsma
User
Posts: 252
Joined: 18-Apr-2006
# Posted on: 26-Aug-2008 14:06:13   

Otis wrote:

The fixed linq provider is attached.

This still doesn't seem to work with the build you attached:


      [TestMethod()]
        public void LlblgenSelectBasedOnSubtype2()
        {
            IQueryable<DoelpakketElementEntity> e = _linqMetaData.DoelpakketElement
                .Where(x => x.Element is ActiviteitEntity);

            foreach (DoelpakketElementEntity entity in e)
            {
                Console.WriteLine(entity);
            }
        }

output:


: Initial expression to process:
value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource2`1[CC.ECDGenie.Dal.EntityClasses.DoelpakketElementEntity]).Where(x => (x.Element Is ActiviteitEntity))
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query: 
    Query: SELECT DISTINCT [LPA_L2].[id] AS [Id], [LPA_L2].[creator_account_id] AS [CreatorAccountId], [LPA_L2].[versie_startdatum] AS [VersieStartdatum], [LPA_L2].[versie_einddatum] AS [VersieEinddatum], [LPA_L2].[versie_nummer] AS [VersieNummer], [LPA_L2].[versie_object_id] AS [VersieObjectId], [LPA_L2].[parent_doelpakket_element_id] AS [ParentDoelpakketElementId], [LPA_L2].[duur_keer] AS [DuurKeer], [LPA_L2].[ordinal] AS [Ordinal], [LPA_L2].[doelpakket_id] AS [DoelpakketId], [LPA_L2].[element_id] AS [ElementId] FROM ( [dbo].[tb_ECDGenie_Element] [LPA_L1] (nolock) INNER JOIN [dbo].[tb_ECDGenie_DoelpakketElement] [LPA_L2] (nolock) ON  [LPA_L1].[id]=[LPA_L2].[element_id]) WHERE ( ( ( ( ( [LPLA_2].[id] IS NOT NULL)))))

Method Exit: CreateSelectDQ
Method Exit: CreatePagingSelectDQ: no paging.
TestCase 'CC.ECDGenie.Dal.UnitTests.LlblgenTests.LlblgenSelectBasedOnSubtype2'
failed: SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: The multi-part identifier "LPLA_2.id" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
    SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: The multi-part identifier "LPLA_2.id" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception. ---> System.Data.SqlClient.SqlException: The multi-part identifier "LPLA_2.id" could not be bound.
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
    at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
    at System.Data.SqlClient.SqlDataReader.get_MetaData()
    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
    at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
    at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
       --- End of inner exception stack trace ---
    at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, IEntityFactory2 entityFactory, IEntityCollection2 collectionToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo, Boolean allowDuplicates, IEntityFields2 fieldsUsedForQuery)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollectionInternal(IEntityCollection2 collectionToFill, IRelationPredicateBucket& filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection(IEntityCollection2 collectionToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath2 prefetchPath, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider2.ExecuteEntityProjection(QueryExpression toExecute)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute(Expression expression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.Execute()
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
    D:\Projects\dotNet\Net3.5\CC.ECDGenie\MainLine\Dal\CC.ECDGenie.Dal.UnitTests\LlblgenTests.cs(131,0): at CC.ECDGenie.Dal.UnitTests.LlblgenTests.LlblgenSelectBasedOnSubtype2()

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 26-Aug-2008 14:13:29   

Hmm... My test uses a targetperentityhierarchy hierarchy, though that shouldn't make a difference. I'll see if I can repro this.

(edit) it indeed doesn't work with a hierarchy of TargetPerEntity... confused Looking into it.

(edit) it forgets to add the relation to the subtype for some obscure reason (in the ormsupportclasses). the relation is likely set between supertype and fk side and the type filter apparently doesn't force the runtime to add the additional hierarchy relation. which is strange.

(edit) normally, you'd add the relation: ActiviteitEntity - DoelpakketElementEntity to the relationcollection, getting the filter for free. For performance reasons it doesn't join every subtype to the join, however it forgets to add the additional hierarchy relations to the subtypes mentioned in predicates. I'll add that code.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 26-Aug-2008 15:05:19   

Got it. an extra call to an already available utility routine did the trick (the same logic was already applied to derived tables and dynamic lists... apparently not to entity collection fetches... ) I've added the fix to the general inheritance relation retrieval routine so it should work in any sitiuation. See attachment.

Frans Bouma | Lead developer LLBLGen Pro
wtijsma
User
Posts: 252
Joined: 18-Apr-2006
# Posted on: 27-Aug-2008 17:52:48   

Otis wrote:

Got it. an extra call to an already available utility routine did the trick (the same logic was already applied to derived tables and dynamic lists... apparently not to entity collection fetches... ) I've added the fix to the general inheritance relation retrieval routine so it should work in any sitiuation. See attachment.

I don't know if it's introduced in the latest build you attached here, but we seem to have problems with the most basic prefetch paths in combination with inheritance hiearchies:

  • ActiviteitEntity inherits from ElementEntity
  • Categorieen is a N-M relation
  • ElementCategorieen is a 1-N relation

        [TestMethod()]
        public void Categorieen()
        {
            _linqMetaData.Element
                .WithPath(prefetch => prefetch.Prefetch(element => element.Categorieen))
                .ToList()
                .ForEach(Console.WriteLine);
        }       
        
        [TestMethod()]
        public void ElementCategorieen()
        {
            _linqMetaData.Element
                .WithPath(prefetch => prefetch.Prefetch(element => element.ElementCategorieen))
                .ToList()
                .ForEach(Console.WriteLine);
        }

Output 1:


: Initial expression to process:
value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource2`1[ CC.ECDGenie.Dal.EntityClasses.ElementEntity]).WithPath(value( SD.LLBLGen.Pro.LinqSupportClasses.IPathEdge[]))
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query: 
    Query: SELECT DISTINCT [dbo].[tb_ECDGenie_Element].[id] AS [F3_0], [dbo].[tb_ECDGenie_Element].[naam] AS [F3_1], [dbo].[tb_ECDGenie_Element].[versie_startdatum] AS [F3_2], [dbo].[tb_ECDGenie_Element].[omschrijving] AS [F3_3], [dbo].[tb_ECDGenie_Element].[creator_account_id] AS [F3_4], [dbo].[tb_ECDGenie_Element].[versie_einddatum] AS [F3_5], [dbo].[tb_ECDGenie_Element].[versie_nummer] AS [F3_6], [dbo].[tb_ECDGenie_Element].[versie_object_id] AS [F3_7], [dbo].[tb_ECDGenie_Activiteit].[id] AS [F1_8], [dbo].[tb_ECDGenie_Activiteit].[is_afdelings_overschrijdend] AS [F1_9], [dbo].[tb_ECDGenie_Activiteit].[financierings_methode_id] AS [F1_10], [dbo].[tb_ECDGenie_Activiteit].[is_plan_prioriteit] AS [F1_11], [dbo].[tb_ECDGenie_Activiteit].[functiegroep_id] AS [F1_12], [dbo].[tb_ECDGenie_Activiteit].[awbz_functie_id] AS [F1_13], [dbo].[tb_ECDGenie_Doel].[id] AS [F2_8], [dbo].[tb_ECDGenie_Formulier].[id] AS [F4_8], [dbo].[tb_ECDGenie_Formulier].[dynform_id] AS [F4_9], [dbo].[tb_ECDGenie_Hulpmiddel].[id] AS [F5_8], [dbo].[tb_ECDGenie_Instructie].[id] AS [F6_8], [dbo].[tb_ECDGenie_Instructie].[instructie_tekst] AS [F6_9] FROM ((((( [dbo].[tb_ECDGenie_Element] (nolock) LEFT JOIN [dbo].[tb_ECDGenie_Activiteit] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Activiteit].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Doel] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Doel].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Formulier] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Formulier].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Hulpmiddel] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Hulpmiddel].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Instructie] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Instructie].[id])

Method Exit: CreateSelectDQ
Method Exit: CreatePagingSelectDQ: no paging.
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
TestCase 'CC.ECDGenie.Dal.UnitTests.LlblgenTests.Categorieen'
failed: SD.LLBLGen.Pro.ORMSupportClasses.ORMRelationException: Relation at index 2 doesn't contain an entity already added to the FROM clause. Bad alias?
    at SD.LLBLGen.Pro.ORMSupportClasses.RelationCollection.ToQueryTextInternal(Int32& uniqueMarker, Boolean ansiJoins, String& nonAnsiWhereClause, String nonAnsiRootTableReference, String nonAnsiFieldSuffix)
    at SD.LLBLGen.Pro.ORMSupportClasses.RelationCollection.ToQueryText(Int32& uniqueMarker)
    at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Boolean relationsSpecified, Boolean sortClausesSpecified)
    at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause)
    at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreatePagingSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)
    at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.CreateSelectDQ(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfoObjects, IPredicateExpression filter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollectionInternal(IEntityCollection2 collectionToFill, IRelationPredicateBucket& filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchPrefetchPath(IEntityCollection2 rootEntities, IRelationPredicateBucket filterBucket, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath2 prefetchPath, Boolean forceParameterizedPPath)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection(IEntityCollection2 collectionToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath2 prefetchPath, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider2.ExecuteEntityProjection(QueryExpression toExecute)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute(Expression expression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.Execute()
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
    D:\Projects\dotNet\Net3.5\CC.ECDGenie\MainLine\Dal\CC.ECDGenie.Dal.UnitTests\LlblgenTests.cs(103,0): at CC.ECDGenie.Dal.UnitTests.LlblgenTests.Categorieen()


Output 2



------ Test started: Assembly: CC.ECDGenie.Dal.UnitTests.dll ------

: Initial expression to process:
value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource2`1[ CC.ECDGenie.Dal.EntityClasses.ElementEntity]).WithPath(value( SD.LLBLGen.Pro.LinqSupportClasses.IPathEdge[]))
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query: 
    Query: SELECT DISTINCT [dbo].[tb_ECDGenie_Element].[id] AS [F3_0], [dbo].[tb_ECDGenie_Element].[naam] AS [F3_1], [dbo].[tb_ECDGenie_Element].[versie_startdatum] AS [F3_2], [dbo].[tb_ECDGenie_Element].[omschrijving] AS [F3_3], [dbo].[tb_ECDGenie_Element].[creator_account_id] AS [F3_4], [dbo].[tb_ECDGenie_Element].[versie_einddatum] AS [F3_5], [dbo].[tb_ECDGenie_Element].[versie_nummer] AS [F3_6], [dbo].[tb_ECDGenie_Element].[versie_object_id] AS [F3_7], [dbo].[tb_ECDGenie_Activiteit].[id] AS [F1_8], [dbo].[tb_ECDGenie_Activiteit].[is_afdelings_overschrijdend] AS [F1_9], [dbo].[tb_ECDGenie_Activiteit].[financierings_methode_id] AS [F1_10], [dbo].[tb_ECDGenie_Activiteit].[is_plan_prioriteit] AS [F1_11], [dbo].[tb_ECDGenie_Activiteit].[functiegroep_id] AS [F1_12], [dbo].[tb_ECDGenie_Activiteit].[awbz_functie_id] AS [F1_13], [dbo].[tb_ECDGenie_Doel].[id] AS [F2_8], [dbo].[tb_ECDGenie_Formulier].[id] AS [F4_8], [dbo].[tb_ECDGenie_Formulier].[dynform_id] AS [F4_9], [dbo].[tb_ECDGenie_Hulpmiddel].[id] AS [F5_8], [dbo].[tb_ECDGenie_Instructie].[id] AS [F6_8], [dbo].[tb_ECDGenie_Instructie].[instructie_tekst] AS [F6_9] FROM ((((( [dbo].[tb_ECDGenie_Element] (nolock) LEFT JOIN [dbo].[tb_ECDGenie_Activiteit] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Activiteit].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Doel] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Doel].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Formulier] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Formulier].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Hulpmiddel] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Hulpmiddel].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Instructie] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Instructie].[id])

Method Exit: CreateSelectDQ
Method Exit: CreatePagingSelectDQ: no paging.
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSubQuery
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query: 
    Query: SELECT [dbo].[tb_ECDGenie_Element].[id] AS [Id] FROM ((((( [dbo].[tb_ECDGenie_Element] (nolock) LEFT JOIN [dbo].[tb_ECDGenie_Activiteit] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Activiteit].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Doel] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Doel].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Formulier] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Formulier].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Hulpmiddel] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Hulpmiddel].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Instructie] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Instructie].[id])

Method Exit: CreateSelectDQ
Method Exit: CreateSubQuery
Generated Sql query: 
    Query: SELECT DISTINCT [dbo].[tb_ECDGenie_CatalogusElementCategorie].[element_categorie_id] AS [CategorieId], [dbo].[tb_ECDGenie_CatalogusElementCategorie].[element_id] AS [ElementId] FROM ((((( [dbo].[tb_ECDGenie_Element] (nolock) LEFT JOIN [dbo].[tb_ECDGenie_Activiteit] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Activiteit].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Doel] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Doel].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Formulier] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Formulier].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Hulpmiddel] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Hulpmiddel].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Instructie] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Instructie].[id]) WHERE ( [dbo].[tb_ECDGenie_CatalogusElementCategorie].[element_id] IN (SELECT [dbo].[tb_ECDGenie_Element].[id] AS [Id] FROM ((((( [dbo].[tb_ECDGenie_Element] (nolock) LEFT JOIN [dbo].[tb_ECDGenie_Activiteit] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Activiteit].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Doel] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Doel].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Formulier] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Formulier].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Hulpmiddel] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Hulpmiddel].[id]) LEFT JOIN [dbo].[tb_ECDGenie_Instructie] (nolock) ON  [dbo].[tb_ECDGenie_Element].[id]=[dbo].[tb_ECDGenie_Instructie].[id])))

Method Exit: CreateSelectDQ
Method Exit: CreatePagingSelectDQ: no paging.
TestCase 'CC.ECDGenie.Dal.UnitTests.LlblgenTests.ElementCategorieen'
failed: SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: The multi-part identifier "dbo.tb_ECDGenie_CatalogusElementCategorie.element_id" could not be bound.
The multi-part identifier "dbo.tb_ECDGenie_CatalogusElementCategorie.element_categorie_id" could not be bound.
The multi-part identifier "dbo.tb_ECDGenie_CatalogusElementCategorie.element_id" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
    SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: The multi-part identifier "dbo.tb_ECDGenie_CatalogusElementCategorie.element_id" could not be bound.
    The multi-part identifier "dbo.tb_ECDGenie_CatalogusElementCategorie.element_categorie_id" could not be bound.
    The multi-part identifier "dbo.tb_ECDGenie_CatalogusElementCategorie.element_id" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception. ---> System.Data.SqlClient.SqlException: The multi-part identifier "dbo.tb_ECDGenie_CatalogusElementCategorie.element_id" could not be bound.
    The multi-part identifier "dbo.tb_ECDGenie_CatalogusElementCategorie.element_categorie_id" could not be bound.
    The multi-part identifier "dbo.tb_ECDGenie_CatalogusElementCategorie.element_id" could not be bound.
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
    at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
    at System.Data.SqlClient.SqlDataReader.get_MetaData()
    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
    at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
    at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
       --- End of inner exception stack trace ---
    at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, IEntityFactory2 entityFactory, IEntityCollection2 collectionToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo, Boolean allowDuplicates, IEntityFields2 fieldsUsedForQuery)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollectionInternal(IEntityCollection2 collectionToFill, IRelationPredicateBucket& filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchPrefetchPath(IEntityCollection2 rootEntities, IRelationPredicateBucket filterBucket, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath2 prefetchPath, Boolean forceParameterizedPPath)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection(IEntityCollection2 collectionToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath2 prefetchPath, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider2.ExecuteEntityProjection(QueryExpression toExecute)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute(Expression expression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.Execute()
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
    D:\Projects\dotNet\Net3.5\CC.ECDGenie\MainLine\Dal\CC.ECDGenie.Dal.UnitTests\LlblgenTests.cs(111,0): at CC.ECDGenie.Dal.UnitTests.LlblgenTests.ElementCategorieen()


Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 27-Aug-2008 18:33:49   

Hmm, our tests ran fine, hence that I attached the build. I'll look into this. If the RTM build doesn't show this issues, it's indeed the fix which causes this...

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 28-Aug-2008 11:05:10   

Reproduced after I switched the threshold to a value below the # of entities in the parent.

(edit) it's indeed caused by the fix. If I comment out these 4 lines it works. It's an alias issue... I'll look into it. The fix also doesn't work properly, as it adds all kinds of stupid relations which aren't necessary. This appears to happen in prefetch paths with subqueries, as the subquery's entities are seen as targets for the outer query with the traverser. This isn't correct of course.

Frans Bouma | Lead developer LLBLGen Pro
wtijsma
User
Posts: 252
Joined: 18-Apr-2006
# Posted on: 28-Aug-2008 11:36:37   

Otis wrote:

This appears to happen in prefetch paths with subqueries, as the subquery's entities are seen as targets for the outer query with the traverser. This isn't correct of course.

If you say so simple_smile Thanks for looking into it...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 28-Aug-2008 11:40:50   

wtijsma wrote:

Otis wrote:

This appears to happen in prefetch paths with subqueries, as the subquery's entities are seen as targets for the outer query with the traverser. This isn't correct of course.

If you say so simple_smile Thanks for looking into it...

Fixed it. See the attached debug build of the ormsupportclasses.

Frans Bouma | Lead developer LLBLGen Pro
wtijsma
User
Posts: 252
Joined: 18-Apr-2006
# Posted on: 28-Aug-2008 13:07:18   

Otis wrote:

wtijsma wrote:

Otis wrote:

This appears to happen in prefetch paths with subqueries, as the subquery's entities are seen as targets for the outer query with the traverser. This isn't correct of course.

If you say so simple_smile Thanks for looking into it...

Fixed it. See the attached debug build of the ormsupportclasses.

Thank you, I've verified it's working again with this build...

wtijsma
User
Posts: 252
Joined: 18-Apr-2006
# Posted on: 28-Aug-2008 16:33:00   

Sorry to bug you again in this thread, but a query like this still fails cry :


[TestMethod()]
public void SelectWhereOnAnySubtype()
{
    _linqMetaData.Doelpakket.Where(x=>x.Elementen.Any(e=>e is ActiviteitEntity))
        .ToList().ForEach(Console.WriteLine);
}

Additional to the above scenarios, DoelpakketEntity has a 1:N relation with ElementEntity.

Output:



: Initial expression to process:
value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource2`1[CC.ECDGenie.Dal.EntityClasses.DoelpakketEntity]).Where(x => x.Elementen.Any(e => (e Is ActiviteitEntity)))
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSubQuery
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query: 
    Query: SELECT [LPLA_2].[versie_object_id] AS [VersieObjectId] FROM [dbo].[tb_ECDGenie_Element] [LPLA_2] (nolock) WHERE ( [LPLA_1].[id] = [DoelpakketElement_].[doelpakket_id] AND ( ( [LPLA_2].[id] IS NOT NULL)))

Method Exit: CreateSelectDQ
Method Exit: CreateSubQuery
Generated Sql query: 
    Query: SELECT [LPLA_1].[id] AS [Id], [LPLA_1].[naam] AS [Naam], [LPLA_1].[omschrijving] AS [Omschrijving], [LPLA_1].[creator_account_id] AS [CreatorAccountId], [LPLA_1].[versie_startdatum] AS [VersieStartdatum], [LPLA_1].[versie_einddatum] AS [VersieEinddatum], [LPLA_1].[versie_nummer] AS [VersieNummer], [LPLA_1].[versie_object_id] AS [VersieObjectId] FROM [dbo].[tb_ECDGenie_Doelpakket] [LPLA_1] (nolock) WHERE ( ( (  EXISTS (SELECT [LPLA_2].[versie_object_id] AS [VersieObjectId] FROM [dbo].[tb_ECDGenie_Element] [LPLA_2] (nolock) WHERE ( [LPLA_1].[id] = [DoelpakketElement_].[doelpakket_id] AND ( ( [LPLA_2].[id] IS NOT NULL)))))))

Method Exit: CreateSelectDQ
Method Exit: CreatePagingSelectDQ: no paging.
TestCase 'CC.ECDGenie.Dal.UnitTests.LlblgenTests.SelectWhereOnSubtype'
failed: SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: The multi-part identifier "DoelpakketElement_.doelpakket_id" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
    SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: The multi-part identifier "DoelpakketElement_.doelpakket_id" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception. ---> System.Data.SqlClient.SqlException: The multi-part identifier "DoelpakketElement_.doelpakket_id" could not be bound.
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
    at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
    at System.Data.SqlClient.SqlDataReader.get_MetaData()
    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
    at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
    at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
       --- End of inner exception stack trace ---
    at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, IEntityFactory2 entityFactory, IEntityCollection2 collectionToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo, Boolean allowDuplicates, IEntityFields2 fieldsUsedForQuery)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollectionInternal(IEntityCollection2 collectionToFill, IRelationPredicateBucket& filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
    at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection(IEntityCollection2 collectionToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath2 prefetchPath, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider2.ExecuteEntityProjection(QueryExpression toExecute)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute(Expression expression)
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.Execute()
    at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
    D:\Projects\dotNet\Net3.5\CC.ECDGenie\MainLine\Dal\CC.ECDGenie.Dal.UnitTests\LlblgenTests.cs(113,0): at CC.ECDGenie.Dal.UnitTests.LlblgenTests.SelectWhereOnSubtype()


Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 28-Aug-2008 17:05:52   

I've to check if this ever worked... I've the feeling it didnt

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 28-Aug-2008 17:20:39   

This is the same problem, only now for the inner query of the FieldCompareSetPredicate (which is used in this case with the EXISTS operator).

This morning when fixing the issue in my previous attempt, I thought about this situation if it could ever happen, I couldn't figure that out.

Guess it didn't take long to prove it indeed can happen haha smile

Anyway, I've to write a crawler to crawl the inner query elements and fix this. Will hopefully not take too long.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 28-Aug-2008 17:53:17   

ok! simple_smile Let's hope this is finally IT.

I've added an additional graph crawler, which finds fieldcomparesetpredicates, and handles them further. The visitor pattern is truly great sunglasses

See attached dll. Let me know if this still fails or succeeds.

(it's a debug build, so if this works, I'll build a release build for you on the build server)

Frans Bouma | Lead developer LLBLGen Pro
wtijsma
User
Posts: 252
Joined: 18-Apr-2006
# Posted on: 01-Sep-2008 11:21:08   

Otis wrote:

ok! simple_smile Let's hope this is finally IT.

I've added an additional graph crawler, which finds fieldcomparesetpredicates, and handles them further. The visitor pattern is truly great sunglasses

See attached dll. Let me know if this still fails or succeeds.

(it's a debug build, so if this works, I'll build a release build for you on the build server)

Works great now!