我的问题是..
我会问我的用户,他是否要删除记录。如果他说是,
我不会真正从表中删除行,但会用 true 更新表的 Deleted 列。但在此之前,我想像在删除行案例中一样检查外键约束,这意味着该值是否被其他表使用。我应该说我的用户该行被其他表使用所以不能删除?
有什么想法我该怎么做。
目前我这样做是为了删除..
public bool Delete(dynamic entity)
{
try
{
//here I want to check, whether this is being used by some other table or not. Foreign key constaint
entity.Deleted = true;
this.SaveChanges();
return true;
}
catch { return false; }
}