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

Unable to cast object of type 'PropertyExpression' to type 'NullConditionalExpression' for some queries with include, and multiple orderbys #8369

Closed
myblindy opened this issue May 3, 2017 · 7 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@myblindy
Copy link

myblindy commented May 3, 2017

I'm getting the exception in the title when using a very specific ThenBy expression. I'll include my EF model in a comment below since it's very large. I don't have a stack trace since I'm using the NuGet package directly, but it should be easily reproducible.

Steps to reproduce

The code that produces the exception, as stripped down as possible.

            var collection = DrdbContext.DrDr
                .Include(w => w.DrHistory)
                    .ThenInclude(w => w.StatusNavigation)
                .Include(w => w.DrHistory)
                    .ThenInclude(w => w.AssignedNavigation)
                .Include(w => w.ProjectNavigation)
                .Include(w => w.AtaNavigation)

            var DrCollection = await collection
                    .OrderBy(w => w.ProjectNavigation.Nn).ThenBy(w => w.ProjDr)
                    .ToListAsync();

Removing ThenBy fixes it. Swapping the lambda expressions between OrderBy and ThenBy also fixes it. Though obviously the result isn't as intended.

Further technical details

EF Core version: v2.0.0-preview2-24770
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 7 SP1
IDE: Visual Studio 2017

@myblindy
Copy link
Author

myblindy commented May 3, 2017

The Context

    public partial class DrdbContext : DbContext
    {
        public virtual DbSet<DrAta> DrAta { get; set; }
        public virtual DbSet<DrDr> DrDr { get; set; }
        public virtual DbSet<DrEmployee> DrEmployee { get; set; }
        public virtual DbSet<DrHistory> DrHistory { get; set; }
        public virtual DbSet<DrProj> DrProj { get; set; }
        public virtual DbSet<DrStatus> DrStatus { get; set; }

        public DrdbContext(DbContextOptions<DrdbContext> options) : base(options)
        {
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<DrAta>(entity =>
            {
                entity.ToTable("dr_ata");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Descr)
                    .IsRequired()
                    .HasColumnName("descr")
                    .HasColumnType("char(100)");
            });

            modelBuilder.Entity<DrDr>(entity =>
            {
                entity.ToTable("dr_dr");

                entity.HasIndex(e => new { e.Id, e.ProjDr, e.Project, e.DueDate })
                    .HasName("ix_dr_dr3");

                entity.HasIndex(e => new { e.Id, e.DateRequired, e.TestGuide, e.Assigned, e.Referencedata, e.Documentversion, e.Relationshipid, e.Relationshipto, e.Documenttypeid, e.Reproducible, e.Flightcond, e.Mano, e.Load, e.Descr1, e.Descr2, e.DueDate, e.Custsupportref, e.Softwaretitle, e.Dateofrepro, e.Reprodoneby, e.Reprodescr, e.Reprotrainingdevice, e.Reprotechnicalanalysis, e.Softwarelog, e.Softwarelogoriginalname, e.Project, e.Ata, e.ProjDr, e.Priority, e.Discrepancyid })
                    .HasName("ix_dr_dr_priority_project");

                entity.HasIndex(e => new { e.Id, e.DateRequired, e.TestGuide, e.Ata, e.Assigned, e.Referencedata, e.Documentversion, e.Relationshipid, e.Relationshipto, e.Documenttypeid, e.Reproducible, e.Flightcond, e.Mano, e.Load, e.Descr1, e.Descr2, e.DueDate, e.Custsupportref, e.Softwaretitle, e.Dateofrepro, e.Reprodoneby, e.Reprodescr, e.Reprotrainingdevice, e.Reprotechnicalanalysis, e.Softwarelog, e.Softwarelogoriginalname, e.ProjDr, e.Discrepancyid, e.Project, e.Priority })
                    .HasName("ix_dr_dr");

                entity.HasIndex(e => new { e.Id, e.DateRequired, e.TestGuide, e.Ata, e.Assigned, e.Referencedata, e.Documentversion, e.Relationshipid, e.Relationshipto, e.Documenttypeid, e.Reproducible, e.Flightcond, e.Mano, e.Load, e.Descr1, e.Descr2, e.DueDate, e.Custsupportref, e.Softwaretitle, e.Dateofrepro, e.Reprodoneby, e.Reprodescr, e.Reprotrainingdevice, e.Reprotechnicalanalysis, e.Softwarelog, e.Softwarelogoriginalname, e.Project, e.ProjDr, e.Priority, e.Discrepancyid })
                    .HasName("ix_dr_dr2");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .ValueGeneratedNever();

                entity.Property(e => e.Assigned).HasColumnName("assigned");

                entity.Property(e => e.Ata)
                    .HasColumnName("ata")
                    .HasDefaultValueSql("((1))");

                entity.Property(e => e.Custsupportref)
                    .HasColumnName("custsupportref")
                    .HasColumnType("nchar(30)");

                entity.Property(e => e.DateRequired)
                    .HasColumnName("date_required")
                    .HasColumnType("char(12)");

                entity.Property(e => e.Dateofrepro)
                    .HasColumnName("dateofrepro")
                    .HasColumnType("nchar(12)");

                entity.Property(e => e.Descr1)
                    .HasColumnName("descr1")
                    .HasColumnType("varchar(max)");

                entity.Property(e => e.Descr2)
                    .HasColumnName("descr2")
                    .HasColumnType("varchar(max)");

                entity.Property(e => e.Discrepancyid)
                    .HasColumnName("discrepancyid")
                    .HasDefaultValueSql("((2))");

                entity.Property(e => e.Documenttypeid).HasColumnName("documenttypeid");

                entity.Property(e => e.Documentversion)
                    .HasColumnName("documentversion")
                    .HasColumnType("nchar(10)");

                entity.Property(e => e.DueDate)
                    .HasColumnName("due_date")
                    .HasColumnType("nchar(12)");

                entity.Property(e => e.Flightcond)
                    .HasColumnName("flightcond")
                    .HasColumnType("nchar(40)");

                entity.Property(e => e.Load)
                    .HasColumnName("load")
                    .HasColumnType("nchar(25)");

                entity.Property(e => e.Mano)
                    .HasColumnName("mano")
                    .HasColumnType("nchar(40)");

                entity.Property(e => e.Priority)
                    .IsRequired()
                    .HasColumnName("priority")
                    .HasColumnType("char(20)")
                    .HasDefaultValueSql("((0))");

                entity.Property(e => e.ProjDr).HasColumnName("proj_dr");

                entity.Property(e => e.Project).HasColumnName("project");

                entity.Property(e => e.Referencedata)
                    .HasColumnName("referencedata")
                    .HasColumnType("nchar(200)");

                entity.Property(e => e.Relationshipid).HasColumnName("relationshipid");

                entity.Property(e => e.Relationshipto).HasColumnName("relationshipto");

                entity.Property(e => e.Reprodescr)
                    .HasColumnName("reprodescr")
                    .HasColumnType("varchar(max)");

                entity.Property(e => e.Reprodoneby)
                    .HasColumnName("reprodoneby")
                    .HasColumnType("nchar(30)");

                entity.Property(e => e.Reproducible).HasColumnName("reproducible");

                entity.Property(e => e.Reprotechnicalanalysis)
                    .HasColumnName("reprotechnicalanalysis")
                    .HasColumnType("varchar(max)");

                entity.Property(e => e.Reprotrainingdevice)
                    .HasColumnName("reprotrainingdevice")
                    .HasColumnType("nchar(40)");

                entity.Property(e => e.Softwarelog)
                    .HasColumnName("softwarelog")
                    .HasColumnType("nchar(50)");

                entity.Property(e => e.Softwarelogoriginalname)
                    .HasColumnName("softwarelogoriginalname")
                    .HasColumnType("nchar(100)");

                entity.Property(e => e.Softwaretitle)
                    .HasColumnName("softwaretitle")
                    .HasColumnType("nchar(50)");

                entity.Property(e => e.Tags)
                    .HasColumnName("tags")
                    .HasColumnType("varchar(max)");

                entity.Property(e => e.TestGuide)
                    .HasColumnName("test_guide")
                    .HasColumnType("char(50)");

                entity.HasOne(d => d.AtaNavigation)
                    .WithMany(p => p.DrDr)
                    .HasForeignKey(d => d.Ata)
                    .HasConstraintName("FK_dr_dr_dr_ata");

                entity.HasOne(d => d.ProjectNavigation)
                    .WithMany(p => p.DrDr)
                    .HasForeignKey(d => d.Project)
                    .OnDelete(DeleteBehavior.Restrict)
                    .HasConstraintName("FK_dr_dr_dr_proj");
            });

            modelBuilder.Entity<DrEmployee>(entity =>
            {
                entity.ToTable("dr_employee");

                entity.HasIndex(e => new { e.Id, e.Mname, e.Initials, e.Addhistory, e.Addnewdr, e.Viewinternaldr, e.Isactive, e.Viewewohwtengdr, e.Viewewodr, e.Username, e.Lname, e.Fname })
                    .HasName("ix_dr_employee_username")
                    .IsUnique();

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .ValueGeneratedOnAdd();

                entity.Property(e => e.Addhistory)
                    .HasColumnName("addhistory")
                    .HasDefaultValueSql("((0))");

                entity.Property(e => e.Addnewdr)
                    .HasColumnName("addnewdr")
                    .HasDefaultValueSql("((0))");

                entity.Property(e => e.Fname)
                    .IsRequired()
                    .HasColumnName("fname")
                    .HasColumnType("char(50)");

                entity.Property(e => e.Initials)
                    .HasColumnName("initials")
                    .HasColumnType("char(5)");

                entity.Property(e => e.Isactive)
                    .HasColumnName("isactive")
                    .HasDefaultValueSql("((1))");

                entity.Property(e => e.Lname)
                    .IsRequired()
                    .HasColumnName("lname")
                    .HasColumnType("char(50)");

                entity.Property(e => e.Mname)
                    .HasColumnName("mname")
                    .HasColumnType("char(20)");

                entity.Property(e => e.Username)
                    .HasColumnName("username")
                    .HasColumnType("char(20)");

                entity.Property(e => e.Viewewodr)
                    .HasColumnName("viewewodr")
                    .HasDefaultValueSql("((0))");

                entity.Property(e => e.Viewewohwtengdr)
                    .HasColumnName("viewewohwtengdr")
                    .HasDefaultValueSql("((0))");

                entity.Property(e => e.Viewinternaldr)
                    .HasColumnName("viewinternaldr")
                    .HasDefaultValueSql("((0))");

                entity.HasOne(d => d.IdNavigation)
                    .WithOne(p => p.InverseIdNavigation)
                    .HasForeignKey<DrEmployee>(d => d.Id)
                    .OnDelete(DeleteBehavior.Restrict)
                    .HasConstraintName("FK_dr_employee_dr_employee");
            });

            modelBuilder.Entity<DrHistory>(entity =>
            {
                entity.HasKey(e => new { e.DrNum, e.HistNum })
                    .HasName("PK_dr_history_1");

                entity.ToTable("dr_history");

                entity.HasIndex(e => new { e.DrNum, e.HistNum, e.Status })
                    .HasName("pk_dr_history")
                    .IsUnique();

                entity.HasIndex(e => new { e.HistNum, e.DrNum, e.AttachmentId })
                    .HasName("ix_dr_history_attachments");

                entity.HasIndex(e => new { e.Date, e.Version, e.Author, e.Descr, e.Assigned, e.Enteredby, e.Fixedfilesgroup, e.Addedfilesgroup, e.Deletedfilesgroup, e.AttachmentId, e.Internal, e.LogUserId, e.Status, e.DrNum, e.HistNum })
                    .HasName("ix_dr_history_drnum_histnum")
                    .IsUnique();

                entity.Property(e => e.DrNum).HasColumnName("dr_num");

                entity.Property(e => e.HistNum).HasColumnName("hist_num");

                entity.Property(e => e.Addedfilesgroup).HasColumnName("addedfilesgroup");

                entity.Property(e => e.Assigned).HasColumnName("assigned");

                entity.Property(e => e.AttachmentId).HasColumnName("attachmentID");

                entity.Property(e => e.Author)
                    .HasColumnName("author")
                    .HasColumnType("char(30)");

                entity.Property(e => e.Date)
                    .HasColumnName("date")
                    .HasColumnType("char(10)");

                entity.Property(e => e.Deletedfilesgroup).HasColumnName("deletedfilesgroup");

                entity.Property(e => e.Descr)
                    .HasColumnName("descr")
                    .HasColumnType("varchar(max)");

                entity.Property(e => e.Enteredby)
                    .HasColumnName("enteredby")
                    .HasColumnType("char(30)");

                entity.Property(e => e.Fixedfilesgroup).HasColumnName("fixedfilesgroup");

                entity.Property(e => e.Internal).HasColumnName("internal");

                entity.Property(e => e.LogUserId).HasColumnName("log_user_id");

                entity.Property(e => e.Status).HasColumnName("status");

                entity.Property(e => e.Version)
                    .HasColumnName("version")
                    .HasColumnType("char(50)");

                entity.HasOne(d => d.AssignedNavigation)
                    .WithMany(p => p.DrHistory)
                    .HasForeignKey(d => d.Assigned)
                    .HasConstraintName("FK_dr_history_dr_employee");

                entity.HasOne(d => d.DrNumNavigation)
                    .WithMany(p => p.DrHistory)
                    .HasForeignKey(d => d.DrNum)
                    .HasConstraintName("FK_dr_history_dr_dr");

                entity.HasOne(d => d.StatusNavigation)
                    .WithMany(p => p.DrHistory)
                    .HasForeignKey(d => d.Status)
                    .OnDelete(DeleteBehavior.Restrict)
                    .HasConstraintName("FK_dr_history_dr_status");

                entity.HasOne(d => d.DrHistoryNavigation)
                    .WithOne(p => p.InverseDrHistoryNavigation)
                    .HasForeignKey<DrHistory>(d => new { d.DrNum, d.HistNum })
                    .OnDelete(DeleteBehavior.Restrict)
                    .HasConstraintName("FK_dr_history_dr_history");
            });

            modelBuilder.Entity<DrProj>(entity =>
            {
                entity.ToTable("dr_proj");

                entity.HasIndex(e => new { e.Id, e.Name, e.AcName, e.Customer, e.Nn })
                    .HasName("ix_dr_proj_nn");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.AcName)
                    .HasColumnName("ac_name")
                    .HasColumnType("char(50)");

                entity.Property(e => e.Customer)
                    .IsRequired()
                    .HasColumnName("customer")
                    .HasColumnType("char(20)");

                entity.Property(e => e.LastChange)
                    .HasColumnName("last_change")
                    .HasColumnType("char(10)");

                entity.Property(e => e.Name)
                    .IsRequired()
                    .HasColumnName("name")
                    .HasColumnType("char(50)");

                entity.Property(e => e.Nn)
                    .HasColumnName("nn")
                    .HasColumnType("varchar(10)");
            });

            modelBuilder.Entity<DrStatus>(entity =>
            {
                entity.ToTable("dr_status");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Descr)
                    .HasColumnName("descr")
                    .HasColumnType("char(100)");

                entity.Property(e => e.Sortid).HasColumnName("sortid");

                entity.Property(e => e.Status)
                    .IsRequired()
                    .HasColumnName("status")
                    .HasColumnType("char(20)");
            });
        }
    }

DrDr

    public partial class DrDr
    {
        public DrDr()
        {
            DrHistory = new HashSet<DrHistory>();
        }

        public int Id { get; set; }
        public int ProjDr { get; set; }
        public string DateRequired { get; set; }
        public string Priority { get; set; }
        public string TestGuide { get; set; }
        public int Project { get; set; }
        public short Ata { get; set; }
        public short? Assigned { get; set; }
        public int? Discrepancyid { get; set; }
        public string Referencedata { get; set; }
        public string Documentversion { get; set; }
        public int? Relationshipid { get; set; }
        public int? Relationshipto { get; set; }
        public int? Documenttypeid { get; set; }
        public bool? Reproducible { get; set; }
        public string Flightcond { get; set; }
        public string Mano { get; set; }
        public string Load { get; set; }
        public string Descr1 { get; set; }
        public string Descr2 { get; set; }
        public string DueDate { get; set; }
        public string Custsupportref { get; set; }
        public string Softwaretitle { get; set; }
        public string Dateofrepro { get; set; }
        public string Reprodoneby { get; set; }
        public string Reprodescr { get; set; }
        public string Reprotrainingdevice { get; set; }
        public string Reprotechnicalanalysis { get; set; }
        public string Softwarelog { get; set; }
        public string Softwarelogoriginalname { get; set; }
        public string Tags { get; set; }

        public ICollection<DrHistory> DrHistory { get; set; }
        public DrAta AtaNavigation { get; set; }
        public DrProj ProjectNavigation { get; set; }
    }

DrHistory

    public partial class DrHistory
    {
        public int DrNum { get; set; }
        public int HistNum { get; set; }
        public string Date { get; set; }
        public string Version { get; set; }
        public string Author { get; set; }
        public string Descr { get; set; }
        public bool Internal { get; set; }
        public int? LogUserId { get; set; }
        public int Status { get; set; }
        public short? Assigned { get; set; }
        public string Enteredby { get; set; }
        public int? Fixedfilesgroup { get; set; }
        public int? Addedfilesgroup { get; set; }
        public int? Deletedfilesgroup { get; set; }
        public int? AttachmentId { get; set; }

        public DrEmployee AssignedNavigation { get; set; }
        public DrDr DrNumNavigation { get; set; }
        public DrStatus StatusNavigation { get; set; }
        public DrHistory DrHistoryNavigation { get; set; }
        public DrHistory InverseDrHistoryNavigation { get; set; }
    }

DrStatus

    public partial class DrStatus
    {
        public DrStatus()
        {
            DrHistory = new HashSet<DrHistory>();
        }

        public int Id { get; set; }
        public string Status { get; set; }
        public string Descr { get; set; }
        public int? Sortid { get; set; }

        public ICollection<DrHistory> DrHistory { get; set; }
    }

DrEmployee

    public partial class DrEmployee
    {
        public DrEmployee()
        {
            DrHistory = new HashSet<DrHistory>();
        }

        public short Id { get; set; }
        public string Lname { get; set; }
        public string Fname { get; set; }
        public string Mname { get; set; }
        public string Initials { get; set; }
        public string Username { get; set; }
        public bool? Addhistory { get; set; }
        public bool? Addnewdr { get; set; }
        public bool? Viewinternaldr { get; set; }
        public bool? Isactive { get; set; }
        public bool? Viewewohwtengdr { get; set; }
        public bool? Viewewodr { get; set; }

        public ICollection<DrHistory> DrHistory { get; set; }
        public DrEmployee IdNavigation { get; set; }
        public DrEmployee InverseIdNavigation { get; set; }
    }

DrProj

    public partial class DrProj
    {
        public DrProj()
        {
            DrDr = new HashSet<DrDr>();
        }

        public int Id { get; set; }
        public string Name { get; set; }
        public string AcName { get; set; }
        public string Customer { get; set; }
        public string LastChange { get; set; }
        public string Nn { get; set; }

        public ICollection<DrDr> DrDr { get; set; }
    }

DrAta

    public partial class DrAta
    {
        public DrAta()
        {
            DrDr = new HashSet<DrDr>();
        }

        public short Id { get; set; }
        public string Descr { get; set; }

        public ICollection<DrDr> DrDr { get; set; }
    }

@maumar
Copy link
Contributor

maumar commented May 10, 2017

Simplified repro:

    class Program
    {
        static void Main(string[] args)
        {
            using (var ctx = new DrdbContext())
            {
                ctx.Database.EnsureDeleted();
                ctx.Database.EnsureCreated();
            }

            using (var ctx = new DrdbContext())
            {
                var query = ctx.DrDr
                    .Include(w => w.DrHistory)
                    .OrderBy(w => w.ProjectNavigation.Nn)
                    .ThenBy(w => w.ProjDr);

                var result = query.ToList();
            }
        }
    }

    public class DrdbContext : DbContext
    {
        public virtual DbSet<DrDr> DrDr { get; set; }
        public virtual DbSet<DrHistory> DrHistory { get; set; }
        public virtual DbSet<DrProj> DrProj { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer(@"Server=.;Database=Repro8369;Trusted_Connection=True;MultipleActiveResultSets=True");
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<DrDr>(entity =>
            {
                entity.HasOne(d => d.ProjectNavigation)
                    .WithMany(p => p.DrDr)
                    .HasForeignKey(d => d.Project)
                    .OnDelete(DeleteBehavior.Restrict);
            });
         }
    }

    public class DrDr
    {
        public int Id { get; set; }
        public int ProjDr { get; set; }
        public int Project { get; set; }

        public ICollection<DrHistory> DrHistory { get; set; }
        public DrProj ProjectNavigation { get; set; }
    }

    public class DrHistory
    {
        public int Id { get; set; }
    }

    public class DrProj
    {
        public int Id { get; set; }
        public string Nn { get; set; }

        public ICollection<DrDr> DrDr { get; set; }
    }

@smithaitufe
Copy link

Please what is the state of this issue now? I am having similar error in my project.
I am using Dotnet 2.0.0- Preview1

@smithaitufe
Copy link

smithaitufe commented Jun 19, 2017

I noticed that when I add OrderBy and OrderByDescending clause to my query, I get the error

Unable to cast object of type 'System.Linq.Expressions.PropertyExpression' to type 'Microsoft.EntityFrameworkCore.Query.Expressions.Internal.NullConditionalExpression'

But when I remove them, the code is executed.

I didn't have this error in netcoreapp1.1 until I upgraded to netcoreapp2.0.

This is my code

var books = bookService.GetAllBooks().OrderBy(b=> b.Title).OrderByDescending(b=>b.InsertedAt).ToList();  //does not work
var books = bookService.GetAllBooks().ToList(); //works

GetAllBooks () is a function that simply returns this

   return  context.Books
            .Include(b=>b.Genre)
            .Include(b=>b.Category)
            .Include(b=>b.Publisher)
            .Include(b=>b.AuthorsLink)
            .ThenInclude(al=>al.Author)
            .Include(b=>b.Variants);

##Resolved##

Adding to ToList() before OrderBy solved the error

var books = bookService.GetAllBooks().ToList().OrderBy(b=> b.Title).OrderByDescending(b=>b.InsertedAt).ToList();  //works

@myblindy
Copy link
Author

@smithaitufe that's not a solution, the point is to perform the ordering on the server side, before pagination.

@maumar
Copy link
Contributor

maumar commented Jun 22, 2017

Problem is in the include pipeline, so current workaround would be to write the includes by hand using joins. This is very painful however. The underlying problem doesn't seem complicated so I'm pretty sure it will get fixed before 2.0 is shipped.

maumar added a commit that referenced this issue Jun 27, 2017
….PropertyExpression' to type 'Microsoft.EntityFrameworkCore.Query.Expressions.Internal.NullConditionalExpression'

Problem was that we had incorrect assumption in the include compiler when performing orderby lifting. When looking for duplicate orderings we always assumed that subquery projections would be an expression of a particular shape (methood call wrapped around NullConditionalExpression). However, this is not accurate because any expression could be there if it was a previous orderby expression.

Fix is to look for duplicate expression more defensively, using soft rather than explicit cast and also taking MemberExpression into account.
@maumar maumar changed the title Unable to cast object of type 'System.Linq.Expressions.PropertyExpression' to type 'Microsoft.EntityFrameworkCore.Query.Expressions.Internal.NullConditionalExpression'. Unable to cast object of type 'PropertyExpression' to type 'NullConditionalExpression' for some queries with include, and multiple order by Jun 27, 2017
@maumar maumar changed the title Unable to cast object of type 'PropertyExpression' to type 'NullConditionalExpression' for some queries with include, and multiple order by Unable to cast object of type 'PropertyExpression' to type 'NullConditionalExpression' for some queries with include, and multiple orderbys Jun 27, 2017
maumar added a commit that referenced this issue Jun 27, 2017
…type 'NullConditionalExpression' for some queries with include, and multiple orderbys

Problem was that we had incorrect assumption in the include compiler when performing orderby lifting. When looking for duplicate orderings we always assumed that subquery projections would be an expression of a particular shape (methood call wrapped around NullConditionalExpression). However, this is not accurate because any expression could be there if it was a previous orderby expression.

Fix is to look for duplicate expression more defensively, using soft rather than explicit cast and also taking MemberExpression into account.
maumar added a commit that referenced this issue Jun 27, 2017
…type 'NullConditionalExpression' for some queries with include, and multiple orderbys

Problem was that we had incorrect assumption in the include compiler when performing orderby lifting. When looking for duplicate orderings we always assumed that subquery projections would be an expression of a particular shape (methood call wrapped around NullConditionalExpression). However, this is not accurate because any expression could be there if it was a previous orderby expression.

Fix is to look for duplicate expression more defensively, using soft rather than explicit cast and also taking MemberExpression into account.
maumar added a commit that referenced this issue Jun 28, 2017
…type 'NullConditionalExpression' for some queries with include, and multiple orderbys

Problem was that we had incorrect assumption in the include compiler when performing orderby lifting. When looking for duplicate orderings we always assumed that subquery projections would be an expression of a particular shape (methood call wrapped around NullConditionalExpression). However, this is not accurate because any expression could be there if it was a previous orderby expression.

Fix is to look for duplicate expression more defensively, using soft rather than explicit cast and also taking MemberExpression into account.
maumar added a commit that referenced this issue Jun 28, 2017
…type 'NullConditionalExpression' for some queries with include, and multiple orderbys

Problem was that we had incorrect assumption in the include compiler when performing orderby lifting. When looking for duplicate orderings we always assumed that subquery projections would be an expression of a particular shape (methood call wrapped around NullConditionalExpression). However, this is not accurate because any expression could be there if it was a previous orderby expression.

Fix is to look for duplicate expression more defensively, using soft rather than explicit cast and also taking MemberExpression into account.
maumar added a commit that referenced this issue Jun 28, 2017
…type 'NullConditionalExpression' for some queries with include, and multiple orderbys

Problem was that we had incorrect assumption in the include compiler when performing orderby lifting. When looking for duplicate orderings we always assumed that subquery projections would be an expression of a particular shape (methood call wrapped around NullConditionalExpression). However, this is not accurate because any expression could be there if it was a previous orderby expression.

Fix is to look for duplicate expression more defensively, using soft rather than explicit cast and also taking MemberExpression into account.
@maumar
Copy link
Contributor

maumar commented Jun 28, 2017

fixed in fafb2dd

@maumar maumar closed this as completed Jun 28, 2017
@maumar maumar added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jun 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

4 participants