如何自动化 Subsonic 3 审核字段,使其像 Subsonic 2 一样工作

发布于 2024-08-07 17:47:29 字数 144 浏览 1 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暗藏城府 2024-08-14 17:47:29

您需要使用 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.

等风也等你 2024-08-14 17:47:29

我真的想完全坚持使用 SimpleRepository,它非常适合我们目前的需求。

因此,我的直接解决方案是让我的所有域模型类都继承自 DataEntity 抽象类:

public abstract class DataEntity {

        public string Name { get; set; }
        public int ID { get; set; }

        public string CreatedBy { get; set; }
        public DateTime CreatedOn { get; set; }
        public string ModifiedBy { get; set; }
        public DateTime ModifiedOn { get; set; }
        public bool IsDeleted { get; set; }

      }

大家怎么看?这些属性不仅仅用于记账,它们还与应用程序域模型相关,因此我认为最好将它们视为 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:

public abstract class DataEntity {

        public string Name { get; set; }
        public int ID { get; set; }

        public string CreatedBy { get; set; }
        public DateTime CreatedOn { get; set; }
        public string ModifiedBy { get; set; }
        public DateTime ModifiedOn { get; set; }
        public bool IsDeleted { get; set; }

      }

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文