Problem executing a stored proc
Hi all, Just looking for any help here.
I'm trying to:
IQuery query = sess.CreateSQLQuery(
"exec dbo.GetPLIsUserIsAssignedTo :userName")
.AddEntity(typeof( ProjectLevelItem ) )
.SetString("userName",userName)
;
IList<ProjectLevelItem> PLIsUserIsAssignedTo = query.List<ProjectLevelItem>();
I'm getting an error :
System.IndexOutOfRangeException: [ProjectLevelItemId]
I can post all the gory details if need be, but to put it in a nushell,
ProjectLevelItemID is the column name in the actual DB
ID is the property name in object.
I've set the proc to return both Id and ProjectLevelItemId, but still get the exact same error.
Anyone seen this?
It did the same damn thing when I had it set up as straight SQL in my code.
i changed it to a proc to simplify.
Actually, let me just post the gory details while i'm here.
[IndexOutOfRangeException: [ProjectLevelItemId]] System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) +6235438 System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) +249 NHibernate.Driver.NHybridDataReader.GetOrdinal(String name) +26 NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name) +133 NHibernate.Loader.Loader.GetKeyFromResultSet(Int32 i, IEntityPersister persister, Object id, IDataReader rs, ISessionImplementor session) +195 NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode[] lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey[] keys, Boolean returnProxies) +134 NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +1344 NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +105 NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +201
[ADOException: could not execute query [ exec dbo.GetPLIsUserIsAssignedTo @p0 ] Name:userName - Value: [SQL: exec dbo.GetPLIsUserIsAssignedTo @p0]] NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +606 NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet1 querySpaces, IType[] resultTypes) +136 NHibernate.Impl.SessionImpl.ListCustomQuery(ICustomQuery customQuery, QueryParameters queryParameters, IList results) +228 NHibernate.Impl.SessionImpl.List(NativeSQLQuerySpecification spec, QueryParameters queryParameters, IList results) +203 NHibernate.Impl.SessionImpl.List(NativeSQLQuerySpecification spec, QueryParameters queryParameters) +187 NHibernate.Impl.SqlQueryImpl.List() +187 TA.PTS2.Data.nHibernateSQL_UserRepository.GetPLIsUserIsAssignedTo(String userName) in C:\VSSProjects\TransAssociates\TransAssociatesInternal\TA.PTS2\TA.PTS2.Data\DataAccess\nHibernateSQL\nHibernateSQL_UserRepository.cs:244 TA.PTS2.Web.Controllers.ProjectController.Portal() in C:\VSSProjects\TransAssociates\TransAssociatesInternal\TA.PTS2\TA.PTS2.Web\Controllers\ProjectController.cs:741 lambda_method(ExecutionScope , ControllerBase , Object[] ) +30 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary
2 parameters) +236 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +31 System.Web.Mvc.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a() +85 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func
1 continuation) +631891 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +288 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +632228 System.Web.Mvc.Controller.ExecuteCore() +125 System.Web.Mvc.<>cDisplayClass8.b4() +48 System.Web.Mvc.Async.<>cDisplayClass1.b0() +21 System.Web.Mvc.Async.<>c__DisplayClass81.<BeginSynchronous>b__7(IAsyncResult _) +15 System.Web.Mvc.Async.WrappedAsyncResult
1.End() +85 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +51 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +454 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +263
The SP runs just fine as the user account concerned, and returns everything necessary to hydrate the object.
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Paul Batum on 11 Mar, 2010 05:53 AM
Have you tried asking on the nhibernate users mailing list? Your question is more about NH usage than the FNH mappings.
Paul Batum resolved this discussion on 11 Mar, 2010 05:53 AM.