求解:NHibernate抛出System.Data.SqlClient.SqlException: Incorrect syntax near '-'.
gamix 2006-07-30 08:16:40 异常抛出的地方为:
Guid contactID = new Guid("3aef1acd-2c5c-4d04-ba73-8760be343cfb");
ContactRole foundRole = contactProfileFactory.GetByID(contactID, false);
GetByID方法的实现为:
public T GetByID(ID id, bool shouldlock)
{
T entity;
if (shouldlock)
{
entity = (T)session.Load(persistentType, id, LockMode.Upgrade);
}
else
{
entity = (T)session.Load(persistentType, id);
}
return entity;
}
其中这里T为ContactRole类型,ID为System.Guid类型。
但是每次执行到Load方法的时候就会抛出NHibernate.ADOException: could not load: [IGS.SMP.BaseType.ContactRole#3aef1acd-2c5c-4d04-ba73-8760be343cfb]
---> System.Data.SqlClient.SqlException: Incorrect syntax near '-'.