This issue should be fixed in the trunk. Could you check this with latest
version?
суббота, 10 марта 2012 г. 2:21:55 UTC+6 пользователь -glenn- написал:
>
> Below is an exception I get when calling Count on an NhQueryable object.
> It appears to be this line in the ExpressionParameterVisitor.cs class:
>
> _parameters.Add(expression, new NamedParameter("p" + (_parameters.Count +
> 1), expression.Value, type));
>
> This happens while trying to get the data to populate a Telerik MVC Grid.
> The grid allows columns to be filtered by one or two strings. If no filter
> is specified on the grid or if a filter is specified with only one string
> then the code runs fine. It's when two strings are specified in a filter
> (say, a "starts with" string and an "ends with" string), the NH error
> occurs. The where part of the query is created by a call to Telerik code:
>
> Expression<Func<T, bool>> where =
> ExpressionBuilder.Expression<T>(command.FilterDescriptors);
>
> The command parameter is passed into the AJAX method with the grid filter
> stings, and Telerik's ExpressionBuilder parses it into an Expression.
>
> Then essentially the app does this:
>
> IQueryable<T> query = session.Query<T>();
> if (where != null) query = query.Where(where);
> int rowCount = query.Count();
>
> and it's that Count that gives the error. With my limited understanding
> of what is going on with the expression code, it looks correct to me. The
> left and right parts of the parsed Boolean expression are:
>
> ((IIF((item != null), item.AccountName, null) ??
> "").ToLower().StartsWith("abc".ToLower()) == True)
> ((IIF((item != null), item.AccountName, null) ??
> "").ToLower().EndsWith("def".ToLower()) == True)
>
> But somehow, when NH's VisitConstantExpression is called, the
> _parametersDictionary already has the
> ConstantExpression in it, hence the error message.
>
> -glenn-
>
>
>
> System.ArgumentException was unhandled by user code
> Message=An item with the same key has already been added.
> Source=mscorlib
> StackTrace:
> at System.ThrowHelper.ThrowArgumentException(ExceptionResource
> resource)
> at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue
> value, Boolean add)
> at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue
> value)
> at
> NHibernate.Linq.Visitors.ExpressionParameterVisitor.VisitConstantExpression(ConstantExpression
>
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors\ExpressionParameterVisitor.cs:line
>
> 42
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression
> expression) in :line 0
> at
> NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors\NhExpressionTreeVisitor.cs:line
>
> 32
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitBinaryExpression(BinaryExpression
>
> expression) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression
> expression) in :line 0
> at
> NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors\NhExpressionTreeVisitor.cs:line
>
> 32
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitMethodCallExpression(MethodCallExpression
>
> expression) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression
> expression) in :line 0
> at
> NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors\NhExpressionTreeVisitor.cs:line
>
> 32
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitMethodCallExpression(MethodCallExpression
>
> expression) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression
> expression) in :line 0
> at
> NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors\NhExpressionTreeVisitor.cs:line
>
> 32
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitBinaryExpression(BinaryExpression
>
> expression) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression
> expression) in :line 0
> at
> NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors\NhExpressionTreeVisitor.cs:line
>
> 32
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitBinaryExpression(BinaryExpression
>
> expression) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression
> expression) in :line 0
> at
> NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors\NhExpressionTreeVisitor.cs:line
>
> 32
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitLambdaExpression(LambdaExpression
>
> expression) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression
> expression) in :line 0
> at
> NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors\NhExpressionTreeVisitor.cs:line
>
> 32
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitUnaryExpression(UnaryExpression
>
> expression) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression
> expression) in :line 0
> at
> NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors\NhExpressionTreeVisitor.cs:line
>
> 32
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitAndConvert[T](T
> expression, String methodName) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.<>c__DisplayClass6`1.<VisitAndConvert>b__5(T
>
> expression) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitList[T](ReadOnlyCollection`1
>
> list, Func`2 visitMethod) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitAndConvert[T](ReadOnlyCollection`1
>
> expressions, String callerName) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitMethodCallExpression(MethodCallExpression
>
> expression) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression
> expression) in :line 0
> at
> NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors\NhExpressionTreeVisitor.cs:line
>
> 32
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitAndConvert[T](T
> expression, String methodName) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.<>c__DisplayClass6`1.<VisitAndConvert>b__5(T
>
> expression) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitList[T](ReadOnlyCollection`1
>
> list, Func`2 visitMethod) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitAndConvert[T](ReadOnlyCollection`1
>
> expressions, String callerName) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitMethodCallExpression(MethodCallExpression
>
> expression) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression
> expression) in :line 0
> at
> NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors\NhExpressionTreeVisitor.cs:line
>
> 32
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitAndConvert[T](T
> expression, String methodName) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.<>c__DisplayClass6`1.<VisitAndConvert>b__5(T
>
> expression) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitList[T](ReadOnlyCollection`1
>
> list, Func`2 visitMethod) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitAndConvert[T](ReadOnlyCollection`1
>
> expressions, String callerName) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitMethodCallExpression(MethodCallExpression
>
> expression) in :line 0
> at
> Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression
> expression) in :line 0
> at
> NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors\NhExpressionTreeVisitor.cs:line
>
> 32
> at
> NHibernate.Linq.Visitors.ExpressionParameterVisitor.Visit(Expression
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors\ExpressionParameterVisitor.cs:line
>
> 20
> at NHibernate.Linq.NhLinqExpression..ctor(Expression expression)
> in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\NhLinqExpression.cs:line
> 37
> at NHibernate.Linq.NhQueryProvider.PrepareQuery(Expression
> expression, IQuery& query, NhLinqExpression& nhQuery) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs:line 41
> at NHibernate.Linq.NhQueryProvider.Execute(Expression expression)
> in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs:line 26
> at NHibernate.Linq.NhQueryProvider.Execute[TResult](Expression
> expression) in
> d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs:line 103
> at System.Linq.Queryable.Count[TSource](IQueryable`1 source)
> at
> Website.Services.LookupTableServiceBase`1.GetLookupGrid(GridCommand
> command, IUserInfo`1 userInfo, String userNameMember) in
> G:\Website\Services\LookupTableServiceBase.cs:line 169
> at
> Website.Controllers.LookupTablesController.LookupIndex[T](GridCommand
> command, ILookupTableService`1 lookupService) in
> G:\Website\Controllers\LookupTablesController.cs:line 81
> at
> Website.Controllers.LookupTablesController._NicknameIndex(GridCommand
> command) in G:\Website\Controllers\LookupTablesController.cs:line 475
> 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__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
> at
> System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter
> filter, ActionExecutingContext preContext, Func`1 continuation)
> InnerException:
>
>
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/TD9QKqH_EyAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.