1
我有以下實體:Graphdiff被刪除實體
public class Profile
{
[Required]
public string Name { get; set; }
[Required]
public string Description { get; set; }
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }
public IList<Functionality> Functionalities { get; set; }
}
和
public class Functionality
{
[Required]
public string Name { get; set; }
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }
}
在我服務的方法,當我嘗試以下方法,它從數據庫中刪除的功能對象不在在配置文件的功能列表中:
(...)
var databaseFunctionalities = this
.Repository
.GetByIds<Functionality>(profile
.Functionalities
.ToIdList());
profile.Functionalities.Clear();
profile.Functionalities.AddRange(databaseFunctionalities);
((BaseRepository)this.Repository)
.UpdateGraph(profile,map => map.OwnedCollection(p => p.Functionalities));
this.Repository.SaveChanges();
(...)
有關它的任何想法?
謝謝!