Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrderByDynamic: Value cannot be null. (Parameter 'type') #394

Closed
wtujvk opened this issue Jul 2, 2020 · 2 comments
Closed

OrderByDynamic: Value cannot be null. (Parameter 'type') #394

wtujvk opened this issue Jul 2, 2020 · 2 comments
Assignees

Comments

@wtujvk
Copy link

wtujvk commented Jul 2, 2020

Throw Exception: System.ArgumentNullException:“Value cannot be null. ”
// Type: System.Linq.EnumerableDynamic
// Assembly: Z.Expressions.Eval, Version=4.0.1.0, Culture=neutral, PublicKeyToken=59b66d028979105b
// MVID: 1B08F7D4-0A7D-4667-AB72-4B641D269972
// Assembly location: C:\Users\xx.nuget\packages\z.expressions.eval\4.0.1\lib\netstandard2.1\Z.Expressions.Eval.dll
nuget: System.Linq.Dynamic.Core 1.1.5

[TestClass]
public class Demo
{
    [TestMethod]
    public void OrderByDynamicTest()
    {
      IEnumerable<Model> list = new List<Model>()
      {
       new Model(){ Name = "jack", Age = 44}
      };
        var orderExpression = "name asc";
        var result = list.OrderByDynamic(orderExpression);
        Assert.IsNotNull(result);
    }
 }

public class Model
 {
      public string Name { get; set; }

      public int Age { get; set; }
 }
@JonathanMagnan JonathanMagnan self-assigned this Jul 2, 2020
@JonathanMagnan
Copy link
Member

Hello @wtujvk ,

You are currently mixing System.Linq.Dynamic.Core syntax with the C# Eval Expression library

System.Linq.Dynamic.Core

You must use the OrderBy method, not OrderByDynamic which is belongs our other library.

Here are some example of use:

C# Eval Expression

Require the same syntax as C#, so "x => x.Name"

Let me know if everything is clear,

Best Regards,

Jon


Performance Libraries
context.BulkInsert(list, options => options.BatchSize = 1000);
Entity Framework ExtensionsEntity Framework ClassicBulk OperationsDapper Plus

Runtime Evaluation
Eval.Execute("x + y", new {x = 1, y = 2}); // return 3
C# Eval FunctionSQL Eval Function

@wtujvk
Copy link
Author

wtujvk commented Feb 19, 2021

use nuget System.Linq.Dynamic.Core 1.2.8, it work ok like this:

using System.Linq;
using System.Linq.Dynamic.Core;

var result = list.AsQueryable().OrderBy(orderExpression);

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

No branches or pull requests

2 participants