- Home
- LLBLGen Pro
- LLBLGen Pro Runtime Framework
PrefetchPath2 not working correctly
Joined: 05-Jul-2006
ORM Support 2.0.7.810 C# .net 2.0 adapter sql 2005 express (vs 2005)
the following code will not prefetch the reports to the category
IPrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.CategoryEntity);
prefetch.Add(CategoryEntity.PrefetchPathReport).Sorter.Add(ReportFields.UserDefinedId | SortOperator.Ascending);
EntityCollection<CategoryEntity> categories = new EntityCollection<CategoryEntity>();
gateway.FetchEntityCollection(categories, new RelationPredicateBucket(), 0, new SortExpression(CategoryFields.Description | SortOperator.Ascending), prefetch);
return categories;
this will work correctly
IPrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.CategoryEntity);
prefetch.Add(CategoryEntity.PrefetchPathReport).Sorter.Add(ReportFields.UserDefinedId | SortOperator.Ascending);
EntityCollection<CategoryEntity> categories = new EntityCollection<CategoryEntity>();
gateway.FetchEntityCollection(categories, null, 0, new SortExpression(CategoryFields.Description | SortOperator.Ascending));
foreach(CategoryEntity category in categories)
{
gateway.FetchEntityCollection(category.Report, null, 0, new SortExpression(ReportFields.UserDefinedId | SortOperator.Ascending);
}
return categories;
i check all my projects (DBSpecific, DBGeneric, My API dll, My ADI Test dll) all are using the same sql and support assembily versions. any ideas?
trace
Method Enter: DataAccessAdapterBase.FetchEntityCollection(5)
Method Enter: DataAccessAdapterBase.FetchEntityCollectionInternal(6)
Active Entity Collection Description:
EntityCollection: ReportingFramework.HelperClasses.EntityCollection`1[[ReportingFramework.EntityClasses.CategoryEntity, ReportingFrameworkDomain, Version=1.0.2887.18983, Culture=neutral, PublicKeyToken=null]]. Will contain entities of type: CategoryEntity
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query:
Query: SELECT [ReportingFrameworkMetaData].[dbo].[Category].[Id], [ReportingFrameworkMetaData].[dbo].[Category].[Description] FROM [ReportingFrameworkMetaData].[dbo].[Category] ORDER BY [ReportingFrameworkMetaData].[dbo].[Category].[Description] ASC
Method Exit: CreateSelectDQ
Method Exit: CreatePagingSelectDQ: no paging.
Method Enter: DataAccessAdapterBase.ExecuteMultiRowRetrievalQuery
Method Enter: DataAccessAdapterBase.OpenConnection
: Connection physically opened.
Method Exit: DataAccessAdapterBase.OpenConnection
Executed Sql Query:
Query: SELECT [ReportingFrameworkMetaData].[dbo].[Category].[Id], [ReportingFrameworkMetaData].[dbo].[Category].[Description] FROM [ReportingFrameworkMetaData].[dbo].[Category] ORDER BY [ReportingFrameworkMetaData].[dbo].[Category].[Description] ASC
Method Exit: DataAccessAdapterBase.ExecuteMultiRowRetrievalQuery
Method Exit: DataAccessAdapterBase.FetchEntityCollectionInternal(6)
Method Enter: DataAccessAdapterBase.FetchPrefetchPath
Method Enter: DataAccessAdapterBase.FetchParameterisedPrefetchPath
Method Enter: DataAccessAdapterBase.FetchEntityCollectionInternal(6)
Active Entity Collection Description:
EntityCollection: ReportingFramework.HelperClasses.EntityCollection`1[[ReportingFramework.EntityClasses.ReportEntity, ReportingFrameworkDomain, Version=1.0.2887.18983, Culture=neutral, PublicKeyToken=null]]. Will contain entities of type: ReportEntity
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query:
Query: SELECT [ReportingFrameworkMetaData].[dbo].[Report].[Id], [ReportingFrameworkMetaData].[dbo].[Report].[UserDefinedId], [ReportingFrameworkMetaData].[dbo].[Report].[Title], [ReportingFrameworkMetaData].[dbo].[Report].[Description], [ReportingFrameworkMetaData].[dbo].[Report].[LifeSpan], [ReportingFrameworkMetaData].[dbo].[Report].[CategoryId] FROM [ReportingFrameworkMetaData].[dbo].[Report] WHERE ( [ReportingFrameworkMetaData].[dbo].[Report].[CategoryId] IN (1,2,3)) ORDER BY [ReportingFrameworkMetaData].[dbo].[Report].[UserDefinedId] ASC
Parameter: @CategoryId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1.
Parameter: @CategoryId2 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 3.
Parameter: @CategoryId3 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2.
Method Exit: CreateSelectDQ
Method Exit: CreatePagingSelectDQ: no paging.
Method Enter: DataAccessAdapterBase.ExecuteMultiRowRetrievalQuery
Method Enter: DataAccessAdapterBase.OpenConnection
Method Exit: DataAccessAdapterBase.OpenConnection
Executed Sql Query:
Query: SELECT [ReportingFrameworkMetaData].[dbo].[Report].[Id], [ReportingFrameworkMetaData].[dbo].[Report].[UserDefinedId], [ReportingFrameworkMetaData].[dbo].[Report].[Title], [ReportingFrameworkMetaData].[dbo].[Report].[Description], [ReportingFrameworkMetaData].[dbo].[Report].[LifeSpan], [ReportingFrameworkMetaData].[dbo].[Report].[CategoryId] FROM [ReportingFrameworkMetaData].[dbo].[Report] WHERE ( [ReportingFrameworkMetaData].[dbo].[Report].[CategoryId] IN (@CategoryId1, @CategoryId2, @CategoryId3)) ORDER BY [ReportingFrameworkMetaData].[dbo].[Report].[UserDefinedId] ASC
Parameter: @CategoryId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1.
Parameter: @CategoryId2 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 3.
Parameter: @CategoryId3 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2.
Method Exit: DataAccessAdapterBase.ExecuteMultiRowRetrievalQuery
Method Exit: DataAccessAdapterBase.FetchEntityCollectionInternal(6)
Method Enter: DataAccessAdapterBase.MergeNormal
Method Exit: DataAccessAdapterBase.MergeNormal
Method Exit: DataAccessAdapterBase.FetchParameterisedPrefetchPath
Method Enter: DataAccessAdapterBase.CloseConnection
Method Exit: DataAccessAdapterBase.CloseConnection
Method Exit: DataAccessAdapterBase.FetchEntityCollection(5)
i tested the queries directly against the database, the information is retrieved correctly, but it doesn't seem to be assigning the reports to CategoryEntity.Report
ok, lets try to narrow down the error: try this:
IPrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.CategoryEntity);
prefetch.Add(CategoryEntity.PrefetchPathReport);
EntityCollection<CategoryEntity> categories = new EntityCollection<CategoryEntity>(new CategoryEntityFactory());
gateway.FetchEntityCollection(categories, null, prefetch);
return categories;
very strange, the above code is an exact reproduction of the manual example, may be is related with the generic collection, did you tried with non-generic? did you remove the sorters?
May be you could send me a ddl script with those tables and some test rows so I can reproduce it.
Joined: 05-Jul-2006
I just put together some sample scripts and code to send to repo the problem. everything works. I'm guessing there is a problem with my orginal project. I'm going to scrub and re-gen my original project to see if that addresses the issue.
---EDIT--- Found the problem. Don't override GetHashCode(). Should have known from the start it wasn't good. I removed the override; now my test to passes so I can finally move on.