1

我想用 NHibernate HQL 一次执行以下两条语句:

update CustomFieldValue set Value = :newVal where Key = 1 and Value = :oldVal;
update CustomFieldValue set Value = :newVal where Key = 1 and Value = :oldVal;

我创建了一个字符串并尝试使用

var query = this.Session.CreateQuery(hql);
// ... set parameters
query.ExecuteUpdate();

但我总是得到一个 QuerySyntaxException。NHibernate 3.3.1 不可能做到这一点,还是我做错了什么?

4

1 回答 1

0

我很难理解你为什么要这样做?我是否错过了它,或者您要提交到数据库的命令是否相同?

我完全在这里猜测,但是您是否真的在尝试做类似的事情:

update CustomFieldValue set Value = :newVal1 where Key = 1 and Value = :oldVal1;
update CustomFieldValue set Value = :newVal2 where Key = 1 and Value = :oldVal2;

在我看来,这行得通吗?

于 2018-07-24T21:39:38.963 回答