[EF.Core 2] Incorrect property mapping in DbContext_Include_OrderBy_First

[EF.Core 2] Incorrect property mapping in DbContext_Include_OrderBy_First

Postby azabluda » Mon 04 Dec 2017 09:41

Devart.Data.Oracle.EFCore 9.5.399. The included entity is receiving the value of the root entity
Code: Select all
[TestMethod]
public void DbContext_Include_OrderBy_First()
{
    using (var dbContext = new TestDbContext(ConnectionString))
    {
        dbContext.Database.EnsureDeleted();
        dbContext.Database.EnsureCreated();

        var user = new User { Name = "John" };
        var folder = new Folder { Name = "test", Owner = user };

        dbContext.Add(folder);
        dbContext.SaveChanges();
    }

    // Works fine without .OrderBy
    using (var dbContext = new TestDbContext(ConnectionString))
    {
        var folder = dbContext.Set<Folder>()
            .Include(f => f.Owner)
            .First();
        Assert.AreEqual("test", folder.Name);
        Assert.AreEqual("John", folder.Owner.Name);
    }

    // Works fine without .First
    using (var dbContext = new TestDbContext(ConnectionString))
    {
        var folders = dbContext.Set<Folder>()
            .Include(f => f.Owner)
            .OrderBy(f => f.Id)
            .ToList();
        var folder = folders.First();
        Assert.AreEqual("test", folder.Name);
        Assert.AreEqual("John", folder.Owner.Name);
    }

    // Fails with .OrderBy.First
    using (var dbContext = new TestDbContext(ConnectionString))
    {
        var folder = dbContext.Set<Folder>()
            .Include(f => f.Owner)
            .OrderBy(f => f.Id)
            .First();
        Assert.AreEqual("test", folder.Name);
        Assert.AreEqual("John", folder.Owner.Name); // <<< Assert.AreEqual failed. Expected:<John>. Actual:<test>.
    }
}
I pushed the test to my repo.
azabluda
 
Posts: 34
Joined: Thu 10 Sep 2009 14:45

Re: [EF.Core 2] Incorrect property mapping in DbContext_Include_OrderBy_First

Postby Shalex » Thu 07 Dec 2017 19:49

Thank you for your report. We will notify you about the result of our investigation.
Shalex
Devart Team
 
Posts: 7839
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle