0
我有一些常见的功能,适用于整个我的应用程序更新行为发生时数据库的特定部分(审计线索,修改日期等)。我将使用AuditTrail作为示例。MVC业务逻辑帮手
我应该在哪里存储这些功能?
目前,我将它们存储在的DbContext类
//... my db context class ...
public bool AddAuditEntry(int ID, string objectName)
{
// Here I create a new AuditTrail object, assign values then insert into db.
// This mode doesn't have a controller.
}
// We also have a table that keeps track of modified state for
// client side caching (nothing I have control over)
public bool ModifyObject(int ID)
{
// Here I mark the object id with modified date then save to db
// This particular model doesn't have a controller either.
}
我认为他们应该在模型中属于,但我不太清楚如何实现它。将它们放在控制器中并不是最好的选择,因为其中一些仅与可能没有控制器的特定模型类相关。
与他们在模型中的问题是什么然后是更新实体的最佳方式?
您是否考虑过使用工厂? – Marko