我有一个关于聚合根的问题,他们应该负责删除子对象还是应该由存储库负责?如果我想通过它的 ID 查询一个文件,我应该在我的存储库中为此创建一个特定的方法吗?
我的聚合根的代码片段:
public class Folder {
#region Properties
public Guid Id { get;set; }
public Name { get;set; }
public virtual ICollection<File> Files { get;set; }
#endregion
#region Methods
public File AddFile(string type, string title, bool share = false)
{
///
}
#endregion
}
文件类:
public class File
{
#region Properties
public virtual Folder Folder { get; set; }
public string Title { get; set; }
public string Type { get; set; }
public bool Shared { get; set; }
#endregion
#region Constructor
public File(Folder folder, string type, string title, bool share = false)
{
///
}
#endregion
}
谢谢