C# 如何通过向Nhibernate 3.3.3.4001中的Session.delete(…)发送查询来删除对象

C# 如何通过向Nhibernate 3.3.3.4001中的Session.delete(…)发送查询来删除对象,c#,nhibernate,C#,Nhibernate,我有下面的代码块,它应该最终删除一条记录 long id = 81; SessionInstance.Delete("from Core.Domain.Model.Person as obj where obj.Id =:id", id, NHibernateUtil.Int64); 但在将Nhibernate版本升级到3.3.3.4001后,此代码有一个例外,显示以下消息: 字典中不存在给定的键 为什么?如果要使用位置参数(您需要),语法有点不同: session.Delete("from

我有下面的代码块,它应该最终删除一条记录

long id = 81;
SessionInstance.Delete("from Core.Domain.Model.Person as obj where obj.Id =:id", id, NHibernateUtil.Int64);
但在将Nhibernate版本升级到3.3.3.4001后,此代码有一个例外,显示以下消息:

字典中不存在给定的键


为什么?

如果要使用位置参数(您需要),语法有点不同:

session.Delete("from Product p where p.ProductId = ?", id, NHibernateUtil.Int32);

请添加处理
Core.Domain.Model.Person
的CRUDF的C#代码,从哪个版本升级?奇怪,我假设您已经尝试了Person where Id=:Id和Core.Domain.Model.Person where Id=:Id的
组合,旧版本是3.1,我的问题不是
Person
,因为通过以下更改,我的问题得到了解决:
SessionInstance.Delete(“from Core.Domain.Model.Person as obj where obj.Id=“+Id.ToString())
。为什么?