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

System.Linq.Dynamic.Core.Exceptions.ParseException in IQueryable<object> filled with anonymous type #132

Closed
SuperJMN opened this issue Jan 3, 2018 · 1 comment

Comments

@SuperJMN
Copy link

SuperJMN commented Jan 3, 2018

I'm getting this exception when trying to sort a IEnumerable that contains a dynamic type.

This code reproduces the problem (.NET Core App 2.0)

    class Program
    {
        static void Main(string[] args)
        {
            var p = GetEnumerable();

            p.AsQueryable().OrderBy("Value");
        }

        private static IEnumerable<object> GetEnumerable()
        {
            var random = new Random((int) DateTime.Now.Ticks);

            var p = System.Linq.Enumerable.Range(0, 10).Select(i =>
            {
                return new
                {
                    Id = i,
                    Value = random.Next(),
                };
            });

            return p;
        }
    }

@StefH
Copy link
Collaborator

StefH commented Jan 4, 2018

Not possible because you lose the type when casting to object.

https://stackoverflow.com/questions/10073319/returning-anonymous-type-in-c-sharp

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