Skip to content

Keep navigation properties of associated entities #117

@ghost

Description

The returned entity from UpdateGraph does not contain navigation properties of associated entities, i.e. if we have

public class Foo {
    [Key]
    public int Id { get; set; }
    public Bar Bar { get; set; }
    public string Other { get; set; }
}

public class Bar {
    [Key]
    public int Id { get; set; }
    public Baz Baz { get; set; }
}

public class Baz {
    [Key]
    public int Id { get; set; }
}

and do

        var foo = new Foo {
            Other = "Asdf",  
            Bar = new Bar {
                Baz = new Baz()
            }
        };
        using (var context = new TestContext()) {
            var newObject = context.UpdateGraph(foo, map => map
                .AssociatedEntity(x => x.Bar));
            context.SaveChanges();
        }

then afterwards newObject contains the correct IDs (and row versions), but foo.Bar.Baz is null.

The problem is, I now need another call to the database to get the complete updated entity (which is complicated) or manually copy elements around (which is what I try to avoid in the first place).

Is there any way to get around this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions