Skip to content

Missing related data when inserting data into new item #12181

@johanskoldekrans

Description

@johanskoldekrans

I fetch the data from the database into a new declared object and I dont get the related data like I did in version 2.0.*.

Example:

public class SomeItem
{
     public int Id {get; set;}
     public List<OtherTable1> OtherTable1 {get;set}
}

var data = ctx.SomeTable.AsNoTracking()

.Include(x => x.OtherTable1)
.ThenInclude(x => x.OtherTable2)
.ThenInclude(x => x.SomeOtherTable)

.Include(x => x.OtherTable1)
.ThenInclude(x => x.OtherTable2)
.ThenInclude(x => x.SomeTypeTable)

.Select(c => new SomeItem {
    Id = c.Id,
    OtherTabledata = OtherTable1.ToList() <--This is missing the data from OtherTable2
}).ToList();

In my real life example OtherTable1 has a lot of Include/ThenInclude/ThenIncludes.

should I be doing something different in 2.1 or is this a bug/known issue?

No exceptions... except null exceptions...

Further technical details

EF Core version: 2.1
.Net Core version: 2.1
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 2016
IDE: Visual Studio 2017 15.7.2

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions