Ho il seguente modello:Come aggiornare le entità correlate usando GraphDiff?
public class Customer
{
public int Id {get; set;}
public string Name {get; set;}
public int AddressId {get; set;}
public virtual Address Address {get; set;}
public virtual ICollection<CustomerCategory> Categories {get; set;}
}
public class CustomerCategory
{
public int Id {get; set;}
public int CustomerId {get; set;}
public int CategoryId {get; set;}
public virtual Category Category {get; set;}
}
public class Address
{
public int Id {get; set;}
public string Street{get; set;}
public virtual PostCode PostCode {get; set;}
}
Da quanto sopra, e l'utilizzo di GraphDiff, voglio aggiornare l'aggregato cliente come segue:
dbContext.UpdateGraph<Customer>(entity,
map => map.AssociatedEntity(x => x.Address)
.OwnedCollection(x => x.Categories, with => with.AssociatedEntity(x => x.Category)));
Ma quanto sopra non è l'aggiornamento nulla !!
Qual è il modo corretto di utilizzare GraphDiff in questo caso?
È anche possibile utilizzare [ 'EntityGraphOperations'] (https://github.com/FarhadJabiyev/EntityGraphOperations). È molto facile da usare E definisce automaticamente gli stati di tutte le entità e utilizza la sintassi fluente. –