LLBLGen Pro Version: 5.5.3
When using the QueryFactory .Create() method to generate a new DynamicQuery, if you only give one table to the .From() method, when you try to fetch, it will throw an exception stating "The multi-part identifier 'xxxxx' could not be bound.
The following code throws the exception:
var paymentHeadersQuery = _unityPaymentsQueryFactory.Create()
.From(_unityPaymentsQueryFactory.PaymentHeader)
.Where(PaymentHeaderFields.CheckId.Equal(checkId))
.Select(() => new
{
Id = PaymentHeaderFields.Id.ToValue<int>(),
BillNumber = PaymentHeaderFields.BillNumber.ToValue<string>(),
CheckId = PaymentHeaderFields.CheckId.ToValue<int>()
});
var paymentHeaders = _unityPaymentsAccessAdapter.FetchQuery(paymentHeadersQuery);
Exception that is thrown:
SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: 'An exception was caught during the execution of a retrieval query: The multi-part identifier "Unity_Payments.dbo.tbl_PaymentHeader.CheckId" could not be bound.
The multi-part identifier "Unity_Payments.dbo.tbl_PaymentHeader.Id" could not be bound.
The multi-part identifier "Unity_Payments.dbo.tbl_PaymentHeader.BillNumber" could not be bound.
The multi-part identifier "Unity_Payments.dbo.tbl_PaymentHeader.CheckId" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.'
The following code does not throw the exception:
var paymentHeadersQuery = _unityPaymentsQueryFactory.PaymentHeader
.Where(PaymentHeaderFields.CheckId.Equal(checkId))
.Select(() => new
{
Id = PaymentHeaderFields.Id.ToValue<int>(),
BillNumber = PaymentHeaderFields.BillNumber.ToValue<string>(),
CheckId = PaymentHeaderFields.CheckId.ToValue<int>()
});
var paymentHeaders = _unityPaymentsAccessAdapter.FetchQuery(paymentHeadersQuery);