- Home
- LLBLGen Pro
- LLBLGen Pro Runtime Framework
The multi-part identifier x could not be bound
Posts
Posts: 83
Joined: 01-Feb-2005
Joined: 01-Feb-2005
# Posted on: 24-Sep-2010 00:44:51
Hello,
I am not sure what to do with this. I am having an issue where the query that is being generated looks good but when run it I get “The multi-part identifier x could not be bound” errors. My build is 3.0.10.0611 and I am using SQL 2008.
The project file and an image of the schema are attached.
My initial thought is that something is wrong with the joins but I don’t see the problem.
I have been able to use these tables in other queries with no problem.
Thank you,
Rick
The query:
SELECT (SELECT TOP(@p2) [LPLA_5].[LastActivityDate]
FROM ( [ClientAccessPortalDB].[dbo].[Users] [LPA_L4]
CROSS JOIN [ClientAccessPortalDB].[dbo].[aspnet_Users] [LPA_L5] )
WHERE ( ( ( ( ( ( [LPLA_5].[UserId] = [LPLA_4].[AspnetUserId]) AND ( [LPLA_4].[ClientPortalId] = [LPA_L2].[RowId]))))))
ORDER BY [LPLA_5].[LastActivityDate] DESC) AS [LastLogin]
FROM ( [ClientAccessPortalDB].[dbo].[Clients] [LPA_L1]
CROSS JOIN [ClientAccessPortalDB].[dbo].[ClientPortals] [LPA_L2] )
WHERE ( ( ( ( ( [LPA_L1].[RowId] = [LPA_L2].[ClientId])))))',N'@p2 bigint',@p2=1
The Linq code:
var q = (from c in Repository.For<ClientEntity>()
from cp in Repository.For<ClientPortalEntity>()
where c.RowId == cp.ClientId
select new
{
LastLogin = (from u in Repository.For<UserEntity>()
from a in Repository.For<AspnetUserEntity>()
where a.UserId == u.AspnetUserId && u.ClientPortalId == cp.RowId
orderby a.LastActivityDate descending
select a.LastActivityDate).First(),
}).ToList();
The error:
SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException was unhandled by user code
Message=An exception was caught during the execution of a retrieval query: The multi-part identifier "LPLA_5.UserId" could not be bound.
The multi-part identifier "LPLA_4.AspnetUserId" could not be bound.
The multi-part identifier "LPLA_4.ClientPortalId" could not be bound.
The multi-part identifier "LPLA_5.LastActivityDate" could not be bound.
The multi-part identifier "LPLA_5.LastActivityDate" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
Source=SD.LLBLGen.Pro.ORMSupportClasses.NET20
RuntimeBuild=06252010
RuntimeVersion=3.0.0.0
QueryExecuted=
Query: SELECT (SELECT TOP(@p2) [LPLA_5].[LastActivityDate] FROM ( [ClientAccessPortalDB].[dbo].[Users] [LPA_L4] CROSS JOIN [ClientAccessPortalDB].[dbo].[aspnet_Users] [LPA_L5] ) WHERE ( ( ( ( ( ( [LPLA_5].[UserId] = [LPLA_4].[AspnetUserId]) AND ( [LPLA_4].[ClientPortalId] = [LPA_L2].[RowId])))))) ORDER BY [LPLA_5].[LastActivityDate] DESC) AS [LastLogin] FROM ( [ClientAccessPortalDB].[dbo].[Clients] [LPA_L1] CROSS JOIN [ClientAccessPortalDB].[dbo].[ClientPortals] [LPA_L2] ) WHERE ( ( ( ( ( [LPA_L1].[RowId] = [LPA_L2].[ClientId])))))
Parameter: @p2 : Int64. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 1.
StackTrace:
at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Query\RetrievalQuery.cs:line 132
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchDataReader(IRetrievalQuery queryToExecute, CommandBehavior readerBehavior) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 1576
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchProjection(List`1 valueProjectors, IGeneralDataProjector projector, IRetrievalQuery queryToExecute, Dictionary`2 typeConvertersToRun) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 1713
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 v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 1675
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider2.ExecuteValueListProjection(QueryExpression toExecute) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProProvider2.cs:line 178
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProProviderBase.cs:line 264
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProProviderBase.cs:line 93
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute(Expression expression) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProProviderBase.cs:line 696
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.Execute() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProQuery.cs:line 87
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProQuery.cs:line 162
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at GA.CAP.Website.Utilities.AdminRepository.GetClientSummary2() in C:\Users\rick.MATRIX6\Documents\Visual Studio 2010\Projects\GreatAmerican\gagroup\CAP\trunk\GA.CAP.Website\Utilities\AdminRepository.cs:line 43
at GA.CAP.Website.Controllers.AdminPortalHomeController.Index() in C:\Users\rick.MATRIX6\Documents\Visual Studio 2010\Projects\GreatAmerican\gagroup\CAP\trunk\GA.CAP.Website\Controllers\AdminPortalHomeController.cs:line 26
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
InnerException: System.Data.SqlClient.SqlException
Message=The multi-part identifier "LPLA_5.UserId" could not be bound.
The multi-part identifier "LPLA_4.AspnetUserId" could not be bound.
The multi-part identifier "LPLA_4.ClientPortalId" could not be bound.
The multi-part identifier "LPLA_5.LastActivityDate" could not be bound.
The multi-part identifier "LPLA_5.LastActivityDate" could not be bound.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=16
LineNumber=1
Number=4104
Procedure=""
Server=devtfs01
State=1
StackTrace:
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()
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.ExecuteReader(CommandBehavior behavior)
at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Query\RetrievalQuery.cs:line 112
InnerException: