如何自动化 Subsonic 3 审核字段,使其像 Subsonic 2 一样工作
我在 SimpleRepository 模式下使用 SubSonic 3.0.0.3。我想知道如何让 Subsonic 3 自动创建和填充 2.x 版本中标准的createdon、createdby 等审核字段。
这是我必须使用 T4 模板进行配置的内容吗?
I am using SubSonic 3.0.0.3 in SimpleRepository mode. I was wondering how to get Subsonic 3 to automatically create and populate the createdon, createdby etc audit fields that were standard in version 2.x .
Is this something I have to configure with the T4 templates?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用 ActiveRecord 模板来自动填充审核字段。 SimpleRepository 除了简单的数据访问之外不提供任何其他功能,因此您需要自己填充这些字段。
You'll need to use the ActiveRecord templates to get the audit fields to be automatically populated. SimpleRepository doesn't provide any other functionality than simple data access so you'd need to populate these fields yourself.
我真的想完全坚持使用 SimpleRepository,它非常适合我们目前的需求。
因此,我的直接解决方案是让我的所有域模型类都继承自 DataEntity 抽象类:
大家怎么看?这些属性不仅仅用于记账,它们还与应用程序域模型相关,因此我认为最好将它们视为 DAL 的一等成员。
I really wanted to stick totally with SimpleRepository, its a very good fit for our needs at this point.
So my immediate solution is to have all my domain model classes inherit from a DataEntity abstract class:
What does everyone think? These properties are not just for bookkeeping, they are relevant to the app domain model so I thought it would be better to treat them as first class members of the DAL.