Skip to content

sorting failed on varchar field #35

Open

Description

@wensaint

when the sort filed type is varchar,the sorting will fail into exception.
but success when the field type is number or datetime

Activity

  1. cyilcode commented on Aug 6, 2019

    @cyilcode
    Contributor

    wensaint (@wensaint) Could you please share more information on the Exception, stack trace, your queried object and client side query if any involved.

  2. wensaint commented on Aug 29, 2019

    @wensaint
    Author

    2019-08-29 18:09:19.602 +08:00 [Error] syslog: sysRole
    DynamicQueryBuilder.DynamicQueryBuilderExceptions+DynamicQueryException: DynamicQueryBuilder has encountered an unhandled exception ---> System.ArgumentException: Incorrect number of arguments supplied for call to method 'System.Linq.IOrderedQueryable1[Wensaint.BaseApp.Model.sysRole] OrderBy[sysRole,String](System.Linq.IQueryable1[Wensaint.BaseApp.Model.sysRole], System.Linq.Expressions.Expression1[System.Func2[Wensaint.BaseApp.Model.sysRole,System.String]])'
    Parameter name: method
    at System.Dynamic.Utils.ExpressionUtils.ValidateArgumentCount(MethodBase method, ExpressionType nodeKind, Int32 count, ParameterInfo[] pis)
    at System.Linq.Expressions.Expression.Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2)
    at DynamicQueryBuilder.Visitors.OrderFunctionVisitor.IterateOrderOptions(Boolean& isPreOrdered, Expression& currentNode)
    at DynamicQueryBuilder.Visitors.OrderFunctionVisitor.ApplyOrders()
    at DynamicQueryBuilder.ExpressionBuilder.ApplyFilters(IQueryable currentSet, DynamicQueryOptions dynamicQueryOptions)
    --- End of inner exception stack trace ---
    at DynamicQueryBuilder.ExpressionBuilder.ApplyFilters(IQueryable currentSet, DynamicQueryOptions dynamicQueryOptions)
    at DynamicQueryBuilder.ExpressionBuilder.ApplyFilters[T](IQueryable`1 currentSet, DynamicQueryOptions dynamicQueryOptions)

  3. wensaint commented on Sep 9, 2019

    @wensaint
    Author

    I have fixed the problem by modify the follow file.

    File: OrderFunctionVisitor.cs Line:84-115

    private void IterateOrderOptions(ref bool isPreOrdered, ref Expression currentNode)
    {
    foreach (OrderOptionDetails orderOpts in _orderOptionDetails)
    {
    //if (!_usesCaseInsensitiveSource && orderOpts.ParameterExpression.Type == typeof(string))
    //{
    // currentNode = Expression.Call(
    // GetSortMethod(
    // orderOpts.Direction,
    // orderOpts.ParameterExpression.Type,
    // ref isPreOrdered,
    // orderOpts.CaseSensitive),
    // currentNode,
    // Expression.Quote(orderOpts.Expression),
    // Expression.Constant(orderOpts.CaseSensitive
    // ? StringComparer.InvariantCulture
    // : StringComparer.InvariantCultureIgnoreCase));
    //}
    //else
    //{
    currentNode = Expression.Call(
    GetSortMethod(
    orderOpts.Direction,
    orderOpts.ParameterExpression.Type,
    ref isPreOrdered,
    orderOpts.CaseSensitive),
    currentNode,
    Expression.Quote(orderOpts.Expression));
    //}
    }
    }

    Cem YILMAZ (@cyilcode) please check and merge

  4. wensaint commented on Sep 12, 2019

    @wensaint
    Author

    Cem YILMAZ (@cyilcode) please double check in time. if there is no bug, update and publish it.

  5. cyilcode commented on Sep 13, 2019

    @cyilcode
    Contributor

    wensaint (@wensaint) The version 1.0.3-pre has the fix for this issue already. I am currently testing the new version. I'll be providing a release this Sunday.

  6. wensaint commented on Sep 17, 2019

    @wensaint
    Author

    Cem YILMAZ (@cyilcode) ok,thank u. I am waiting for the new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions