Nhibernate 删除父模型的子级 - MVC3
我有一个页面显示模型详细信息(在本例中为特许经营),但也显示有关特许经营的注释的表格列表。删除其中一条笔记的最佳方法是什么?
目前我有一个特许经营存储库,它负责特许经营模型的所有增删改查操作。我最好创建一个笔记存储库来添加 CRUD 功能吗?或者是否有更简单的方法,例如在特许经营存储库中实施它(或者这会打破一些 ddd 规则,如 srp)?
public class Parent()
{
public string name{get; set;}
public IList<Note> notes{get;set;}
//And so on
}
public class Note()
{
public string content{get; set;}
//And so on
}
I have a page which displays the model details(in this case Franchise), but also displays a tabular list of notes about the franchise. What is the best way to delete one of the notes?
Currently i have a franchiseRepository which takes care of all the crud operations for the franchise Model. Would i be best to create a note repository also to add crud functionality? Or is there an easier way around it, like implementing it within the franchiseRepository(or would that be breaking some ddd rules like srp)?
public class Parent()
{
public string name{get; set;}
public IList<Note> notes{get;set;}
//And so on
}
public class Note()
{
public string content{get; set;}
//And so on
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的父母应该有一个像RemoveNote()这样的方法,它将从列表中删除注释。
在曼尼关系上使用cascade = all-delete-orphan,在映射上使用inverse = true。而且你不应该有 Note 存储库。
Your parent should have a method like RemoveNote() which will remove the note from the list.
use cascade = all-delete-orphan on the on to manny relation and inverse = true on mapping. And you should not have Note repository.