c# - 休眠 Antlr.Runtime.NoViableAltException

标签 c# nhibernate

return NHibernateSession.CreateQuery(@"TRUNCATE TABLE dbo.Exceptions").ExecuteUpdate();

Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. [TRUNCATE TABLE Exceptions] Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. [TRUNCATE TABLE Exceptions]

Source Error:

知道为什么吗?

最佳答案

TRUNCATE TABLE 不是有效的 HQL 语句。

使用CreateSQLQuery代替CreateQuery来执行SQL语句。

关于c# - 休眠 Antlr.Runtime.NoViableAltException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3799087/

相关文章:

c# - csv 文件导入 Azure 存储时出现数据格式问题

c# - 高亮请求的 Elasticsearch.NET NEST 对象初始化器语法

c# - CaSTLe Windsor 注册匹配相同服务的组件

c# - 如何在 typescript 中使用 C# 字典?

c# - 解析 oledb 的参数化字符串

c# - NHibernate 是否应该清除 ISessionFactory.Dispose 上的分布式二级缓存?

c# - 流畅的NHibernate批量数据插入

c# - 跟踪 SQL Server 中创建和更新时间的最佳方法

nhibernate - Entity Framework 和 NHibernate - 缓存仍然是服务层的职责吗?

NHibernate 使用过滤器选择最大值