daelmo wrote:
LPA_F1 is used instead of your "T2". But that shouldn't cause the problem. What is the exception message and stack trace that you are getting and what is the relevant code that produces it?
The following exception message appears:
"An exception was caught during the execution of a retrieval query: The multi-part identifier \"S1.ShopId\" could not be bound.\r\nThe multi-part identifier \"S1.Name\" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception."
The stacktrace is as follows:
at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v4.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Query\RetrievalQuery.cs:line 151
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchDataReader(IRetrievalQuery queryToExecute, CommandBehavior readerBehavior) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v4.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 1574
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchProjection(List1 valueProjectors, IGeneralDataProjector projector, IRetrievalQuery queryToExecute, Dictionary
2 typeConvertersToRun) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v4.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 1735
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchProjection(List1 valueProjectors, IGeneralDataProjector projector, QueryParameters parameters) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v4.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 1697
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchProjection(List
1 valueProjectors, IGeneralDataProjector projector, IEntityFields2 fields, IRelationPredicateBucket filter, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, IGroupByCollection groupByClause, Boolean allowDuplicates, Int32 pageNumber, Int32 pageSize) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v4.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 1656
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchProjection(List1 valueProjectors, IGeneralDataProjector projector, IEntityFields2 fields, IRelationPredicateBucket filter, Int32 maxNumberOfItemsToReturn, Boolean allowDuplicates) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v4.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 1592
at DataAccess.Common.CustomDataAccessAdapter.FetchProjection(List
1 valueProjectors, IGeneralDataProjector projector, IEntityFields2 fields, IRelationPredicateBucket filter, Int32 maxNumberOfItemsToReturn, Boolean allowDuplicates) in d:\Projects\Cow Hills ROS Trunk\DataAccess\Common\CustomDataAccessAdapter.cs:line 2002
at Projections.ProjectionsManager.FetchProjectionImpl[T](ProjectionParams`1 projectionParams) in d:\Projects\Cow Hills ROS Trunk\Projections\Projections\ProjectionsManager.cs:line 64
The query executed is:
SELECT
[ReferenceData].[dbo].[LinkedShop].[ShopKey] AS [Field0],
[ReferenceData].[dbo].[Shop].[ShopId] AS [Field1],
[ReferenceData].[dbo].[Shop].[Name] AS [Field2],
[ReferenceData].[dbo].[LinkedShop].[LinkedShopKey] AS [Field3],
[S1].[ShopId] AS [Field4],
[S1].[Name] AS [Field5]
FROM (( [ReferenceData].[dbo].[LinkedShop]
INNER JOIN [ReferenceData].[dbo].[Shop] [LPA_S1]
ON [ReferenceData].[dbo].[LinkedShop].[LinkedShopKey]=[LPA_S1].[PKey])
INNER JOIN [ReferenceData].[dbo].[Shop]
ON [ReferenceData].[dbo].[LinkedShop].[ShopKey]=[ReferenceData].[dbo].[Shop].[PKey])
As you can see I'm using a projection. We've created a few helper methods to make things a little easier for us. The code is as follows:
var projectionParams = new ProjectionParams<LinkedShopInfo>();
projectionParams.FieldMappings.Add(LinkedShopFields.ShopKey, dto => dto.ShopKey);
projectionParams.FieldMappings.Add(ShopFields.ShopId, dto => dto.ShopId);
projectionParams.FieldMappings.Add(ShopFields.Name, dto => dto.ShopName);
projectionParams.FieldMappings.Add(LinkedShopFields.LinkedShopKey, dto => dto.LinkedShopKey);
projectionParams.FieldMappings.Add(new EntityField2("ShopId", "[S1]", typeof(string)), dto => dto.LinkedShopId);
projectionParams.FieldMappings.Add(new EntityField2("Name", "[S1]", typeof(string)), dto => dto.LinkedShopName);
projectionParams.Filter = new RelationPredicateBucket();
projectionParams.Filter.Relations.Add(new EntityRelation(LinkedShopFields.LinkedShopKey, ShopFields.PKey, RelationType.OneToOne, true, null), "S1");
projectionParams.Filter.Relations.Add(new EntityRelation(LinkedShopFields.ShopKey, ShopFields.PKey, RelationType.OneToOne, true, null));
public class LinkedShopInfo
{
public int ShopKey { get; set; }
public string ShopId { get; set; }
public string ShopName { get; set; }
public int LinkedShopKey { get; set; }
public string LinkedShopId { get; set; }
public string LinkedShopName { get; set; }
}
I hope this information helps. Thanks in advance.