SQLMetal可以生成的节省行创建时间的方法

发布于 2024-08-30 02:15:11 字数 204 浏览 2 评论 0原文

我想保存一行的创建时间,因此我创建了一个日期时间列并将其默认值设置为 Getdate()。但是,当我从 SQLMetal 生成 dbml 文件并从中重新创建数据库时,该函数丢失了。

我在运行 SQLMetal 时将 /functions 参数添加到命令行,但这并没有解决问题。

或者还有其他方法可以节省行创建时间,并且可以通过 SQLMetal 进行逆向工程吗?

I'd like to save the creation time of a row, so I have created a datetime column and set it's Default Value to be Getdate(). But when I generate the dbml file from SQLMetal and re-create the database from it, the function is missing.

I've added the /functions parameter to the command line when running SQLMetal but this didn't fix the problem.

Alternatively is there any other way to save the row creation time, that can be reverse engineered by SQLMetal?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

白云不回头 2024-09-06 02:15:12

我找到了一种方法来解决这个问题,方法是创建一个触发器来在插入后更新列。然而SQLMetal也不提取触发器,因此我使用方法隐藏来重载DataContext的CreateDatabase()方法,并在调用基本方法后添加触发器手册。

这不是一个理想的解决方案,因为编译器不会检查触发器的 SQL 中的错误,但我将创建一个单元测试来自动检查它。

I found a way to solve this by creating a trigger to update the column after an INSERT. However SQLMetal does not extract triggers either, so I've used method hiding to overload the CreateDatabase() method of the DataContext, and add the trigger manual after calling the base method.

Not an ideal solution as there's no compiler checking of the errors in the SQL of the trigger, but I'll create a unit test to check it automatically.

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