如何执行“ExecuteNonQuery” 在城堡活动记录中
我有以下代码通过我们的活动记录 ORM 层执行数据库级别的操作。
public static void Vacuum() {
Execute(
delegate(ISession session, object instance) {
ISQLQuery query =
session.CreateSQLQuery(@"
VACUUM billableaddresses;
")
query.List();
return null;
}, null);
}
通常,当我需要执行这样的非查询时(我承认这种情况很少见),我简单地输入 select '1'; 在查询之后,它足以安抚 Active Record 来将查询作为非查询执行。
但是,postgres 'vacuum' 命令必须单独运行,并且不能作为多语句查询的一部分。
查看 ISQLQuery 接口,似乎没有执行非查询的方法,所以我想知道如何做到这一点?
I have the following code to perform a database level operation through our active record ORM layer.
public static void Vacuum() {
Execute(
delegate(ISession session, object instance) {
ISQLQuery query =
session.CreateSQLQuery(@"
VACUUM billableaddresses;
")
query.List();
return null;
}, null);
}
Normally when I need to do a non-query like this (its very rare I admit) I simple put a select '1'; after the query which appeases Active Record enough to execute the query asa nonquery.
However, the postgres 'vacuum' command, must be run on its own and cannot be part of a multi statement query.
looking ISQLQuery interface, there doesnt seem to be a method to execute a nonquery, so I was wondering how this can be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于特定的数据库调用,您可以从中获取原始 IDbConnection
For specific DB calls you can get a raw IDbConnection from