Это код:
Код: Выделить всё
public class Parent
{
public int Id { get; set; }
public string Description { get; set; }
public ICollection Children { get; set; }
}
public class Child
{
public int Id { get; set; }
public int ParentId { get; set; }
public Parent Parent { get; set; }
public string Data { get; set; }
}
Код: Выделить всё
Parent parent = new Parent()
{
Id = 5, // I already know the user Id
Description = "new description from User";
Children = null; // I don't want the children to be changed
}
dbContext.Parent.Attach(parent);
dbContext.Entry(parent).State = EntityState.Modified;
dbContext.SaveChanges();
Подробнее здесь: https://stackoverflow.com/questions/597 ... e-children
Мобильная версия