Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have some models:

C#
public class RootEntity
{
    public int Id {get; set;}

    public virtual ICollection<AbstractEntity> CollectionA {get; set;}
}

public abstract class AbstractEntity
{
    public int Id {get; set;}
}

public class DerivedEntityA : AbstractEntity
{
    public virtual ICollection<AnotherType> CollectionB {get; set;}
}

public class DerivedEntityB : AbstractEntity
{
    public string Name {get; set;}
}


The relationships of above models are like this:

RootEntity ---> ICollection<AbstractEntity>
                                 ┗━━ DerivedEntityA ---> ICollection<AnotherType>
                                 ┗━━ DerivedEntityB
 --->    has a
┗━━  derived from


Now I want to update a RootEntity entity named rootEntity by using GraphDiff:

C#
context.UpdateGraph(rootEntity, map => map
             .OwnedCollection(r => r.CollectionA, with => with
                 .OwnedCollection(de => de.CollectionB)  // this doesn't work because 'de' doesn't have 'CollectionB'
                 )
     );


So how can I update it properly?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900