У меня есть следующие модели:Как обновить связанные объекты с помощью 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;}
}
Из вышеизложенного и с помощью GraphDiff, я хочу, чтобы обновить агрегат клиента следующим образом:
dbContext.UpdateGraph<Customer>(entity,
map => map.AssociatedEntity(x => x.Address)
.OwnedCollection(x => x.Categories, with => with.AssociatedEntity(x => x.Category)));
Но выше ничего не обновляется !!
Каков правильный способ использования GraphDiff в этом случае?
Вы также можете использовать [ 'EntityGraphOperations'] (https://github.com/FarhadJabiev/EntityGraphOperations). Он очень прост в использовании. И автоматически определяет состояния всех объектов и использует свободный синтаксис. –