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

Client-Side Blazor OrderByDescending #15259

Closed
mkArtakMSFT opened this issue Jun 19, 2019 · 2 comments · Fixed by mono/corefx#319
Closed

Client-Side Blazor OrderByDescending #15259

mkArtakMSFT opened this issue Jun 19, 2019 · 2 comments · Fixed by mono/corefx#319
Assignees

Comments

@mkArtakMSFT
Copy link

From @matheusjulio96 on Wednesday, June 19, 2019 2:02:04 PM

The bug: Execute an OrderByDescending query throw the error 'Unhandled exception rendering component: System.NullReferenceException: Object reference not set to an instance of an object.'

Steps to reproduce the behavior:

  1. Using this version of ASP.NET Core 3.0.0-preview6.19307.2 with Client-Side project
  2. Run this code:
@code{
    class Pet
    {
        public string Name { get; set; }
        public int Age { get; set; }
    }

    protected override void OnInit()
    {
        Pet[] pets = { new Pet { Name="Barley", Age=8 },
                       new Pet { Name="Boots", Age=4 },
                       new Pet { Name="Whiskers", Age=1 } };

        var query = pets.AsQueryable().OrderByDescending(pet => pet.Age);

        foreach (Pet pet in query)
            Console.WriteLine("{0} - {1}", pet.Name, pet.Age);
    }
}
  1. See error Screenshot
    image

Expected behavior: Execute the query and print the values.

Ps: OrderBy query works fine.

Copied from original issue: dotnet/aspnetcore#11371

@matheusjulio96
Copy link

Seems related with #8872

@lewing
Copy link
Member

lewing commented Jun 19, 2019

using System;
using System.Runtime.InteropServices;
using System.Linq;

public class TestQueryableOrderBy
{
    public static void Main (String[] args) {
        OnInit();
        Console.WriteLine ("Hello, World!");
    }

    class Pet
    {
        public string Name { get; set; }
        public int Age { get; set; }
    }

    static void OnInit()
    {
        Pet[] pets = { new Pet { Name="Barley", Age=8 },
                       new Pet { Name="Boots", Age=4 },
                       new Pet { Name="Whiskers", Age=1 } };

        var query = pets.AsQueryable().OrderByDescending(pet => pet.Age);

        foreach (Pet pet in query)
            Console.WriteLine("{0} - {1}", pet.Name, pet.Age);
    }
}
Exception:System.NullReferenceException: Object reference not set to an instance of an object.
  at System.Linq.EnumerableRewriter.FindEnumerableMethod (System.String name, System.Collections.ObjectModel.ReadOnlyCollection`1[T] args, System.Type[] typeArgs) <0x1874028 + 0x000ac> in <7003b7b7722e4d88a36c3d5cbc5c762d>:0 
  at System.Linq.EnumerableRewriter.VisitMethodCall (System.Linq.Expressions.MethodCallExpression m) <0x186d900 + 0x0013c> in <7003b7b7722e4d88a36c3d5cbc5c762d>:0 
  at System.Linq.Expressions.MethodCallExpression.Accept (System.Linq.Expressions.ExpressionVisitor visitor) <0x1866428 + 0x0000c> in <7003b7b7722e4d88a36c3d5cbc5c762d>:0 
  at System.Linq.Expressions.ExpressionVisitor.Visit (System.Linq.Expressions.Expression node) <0x18662f0 + 0x00018> in <7003b7b7722e4d88a36c3d5cbc5c762d>:0 
  at System.Linq.EnumerableQuery`1[T].GetEnumerator () <0x18660e8 + 0x00022> in <7003b7b7722e4d88a36c3d5cbc5c762d>:0 
  at System.Linq.EnumerableQuery`1[T].System.Collections.Generic.IEnumerable<T>.GetEnumerator () <0x1865b10 + 0x00004> in <7003b7b7722e4d88a36c3d5cbc5c762d>:0 
  at TestQueryableOrderBy.OnInit () <0x17d71e0 + 0x00134> in <5bdd73753a1f47d98849c347b9dc492f>:0 
  at TestQueryableOrderBy.Main (System.String[] args) <0x716820 + 0x00000> in <5bdd73753a1f47d98849c347b9dc492f>:0

I'm seeing the same failure with OrderBy though.

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

Successfully merging a pull request may close this issue.

4 participants