Hello,
I get an error in the following scenario:
.......................................................................Expense -- (M:1)--> ScopeFrequency
..............................................................................|
Case -- (1:N) --> Recommendation -- (1:N)--> Proposal
The relations between the entities are:
Case-Recommendation (1:n)
Recommendation-Proposal (1:n)
Expense-ScopeFrequency (m:1)
Proposal is a subtype of Expense with the hierachy type being one target per entity type.
The following code raises an error:
DaoBase.ParameterisedPrefetchPathThreshold = 15;
CaseEntity c = new CaseEntity();
IPrefetchPath pp = new PrefetchPath((int)EntityType.CaseEntity);
pp.Add(CaseEntity.PrefetchPathRecommendation).
SubPath.Add(RecommendationEntity.PrefetchPathProposal).
SubPath.Add(ProposalEntity.PrefetchPathScopeFrequency);
c.FetchUsingPK(1, pp);
The number of Proposal-entities related to each Recommendation-entity exceeds the parameterisedprefetchpathtthreshold.
The error generated is this (copy-pasted from the console in VS2005)
Method Enter: DaoBase.PerformFetchEntityAction
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query:
Query: SELECT [TestDB].[dbo].[Case].[CaseID] AS [CaseId], [TestDB].[dbo].[Case].[CaseName] FROM [TestDB].[dbo].[Case] WHERE ( [TestDB].[dbo].[Case].[CaseID] = @CaseId1)
Parameter: @CaseId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1.
Method Exit: CreateSelectDQ
Method Enter: DaoBase.ExecuteSingleRowRetrievalQuery
'Home.Console.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Transactions\2.0.0.0__b77a5c561934e089\System.Transactions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Home.Console.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Method Exit: DaoBase.ExecuteSingleRowRetrievalQuery
Method Enter: DaoBase.FetchPrefetchPath
Method Enter: DaoBase.PerformGetMultiAction
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query:
Query: SELECT [TestDB].[dbo].[Recommendation].[RecommendationID] AS [RecommendationId], [TestDB].[dbo].[Recommendation].[CaseID] AS [CaseId], [TestDB].[dbo].[Recommendation].[RecommendationName] FROM [TestDB].[dbo].[Recommendation] WHERE ( ( ( ( [TestDB].[dbo].[Recommendation].[CaseID] = @CaseId1))))
Parameter: @CaseId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1.
Method Exit: CreateSelectDQ
Method Exit: CreatePagingSelectDQ: no paging.
Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery
Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery
Method Exit: DaoBase.PerformGetMultiAction
Method Enter: DaoBase.MergeNormal
Method Exit: DaoBase.MergeNormal
Method Enter: DaoBase.FetchPrefetchPath
Method Enter: DaoBase.PerformGetMultiAction
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query:
Query: SELECT DISTINCT [TestDB].[dbo].[Expense].[ExpenseID] AS [F0], [TestDB].[dbo].[Expense].[ExpenseName] AS [F1], [TestDB].[dbo].[Expense].[ScopeFrequencyID] AS [F2], [TestDB].[dbo].[Proposal].[ProposalID] AS [F3], [TestDB].[dbo].[Proposal].[ProposalName] AS [F4], [TestDB].[dbo].[Proposal].[RecommendationID] AS [F5] FROM ( [TestDB].[dbo].[Expense] INNER JOIN [TestDB].[dbo].[Proposal] ON [TestDB].[dbo].[Expense].[ExpenseID]=[TestDB].[dbo].[Proposal].[ProposalID]) WHERE ( [TestDB].[dbo].[Proposal].[ProposalID] IS NOT NULL AND ( ( ( [TestDB].[dbo].[Proposal].[RecommendationID] = @RecommendationId1))))
Parameter: @RecommendationId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1.
Method Exit: CreateSelectDQ
Method Exit: CreatePagingSelectDQ: no paging.
Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery
Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery
Method Exit: DaoBase.PerformGetMultiAction
Method Enter: DaoBase.MergeNormal
Method Exit: DaoBase.MergeNormal
Method Enter: DaoBase.FetchPrefetchPath
Method Enter: DaoBase.PerformGetMultiActionInternal
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSubQuery
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query:
Query: SELECT [TestDB].[dbo].[Expense].[ScopeFrequencyID] AS [ScopeFrequencyId] FROM [TestDB].[dbo].[Expense] WHERE ( ( ( ( [TestDB].[dbo].[Proposal].[RecommendationID] = @RecommendationId1))))
Parameter: @RecommendationId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1.
Method Exit: CreateSelectDQ
Method Exit: CreateSubQuery
Generated Sql query:
Query: SELECT [TestDB].[dbo].[ScopeFrequency].[ScopeFrequencyID] AS [ScopeFrequencyId], [TestDB].[dbo].[ScopeFrequency].[ScopeFrequencyName] FROM [TestDB].[dbo].[ScopeFrequency] WHERE ( ( [TestDB].[dbo].[ScopeFrequency].[ScopeFrequencyID] IN (SELECT [TestDB].[dbo].[Expense].[ScopeFrequencyID] AS [ScopeFrequencyId] FROM [TestDB].[dbo].[Expense] WHERE ( ( ( ( [TestDB].[dbo].[Proposal].[RecommendationID] = @RecommendationId1)))))))
Parameter: @RecommendationId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1.
Method Exit: CreateSelectDQ
Method Exit: CreatePagingSelectDQ: no paging.
Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery
A first chance exception of type 'SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException' occurred in SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll
Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery
SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: The multi-part identifier "TestDB.dbo.Proposal.RecommendationID" 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 "TestDB.dbo.Proposal.RecommendationID" 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)
The configuration is:
LLBLGen V2.0.0.0, Selfservicing, Build: 09282006, .NET2.0, SQL2005
Thanks in advance,
Niels Johansen,
Rehfeld