0
我在sqlserverce上使用连贯NHibernate。 使用NHibernate QueryOver我尝试检索行 - NHibernate的自动生成氨基酸连接查询 ,我得到以下异常:在uniqueidentifier上使用连接时出错 - 将uniqueidentifier转换为数字
[SQL: SELECT tag FROM CheckpointToProtectionGroup cp2pg
JOIN CheckpointStorageObject cp ON cp.id = cp2pg.checkpoint_id
JOIN ProtectionGroupCheckpointStorageObject pg ON pg.id = cp2pg.vpg_id
WHERE cp.CheckpointIdentifierIdentifier = 1111 AND
pg.ProtectionGroupIdentifierGroupGuid =
11111111-1111-1111-1111-111111111111]
---> System.Data.SqlServerCe.SqlCeException:
The conversion is not supported.
[ Type to convert from (if known) = uniqueidentifier,
Type to convert to (if known) = numeric ]
从我所看到的,它似乎试图将值转换 - 11111111-1111 -1111-1111-111111111111到数字,但这个值是一个GUID字段:
CheckpointToProtectionGroup checkpointToProtectionGroup = Session
.QueryOver<CheckpointToProtectionGroup>()
.JoinQueryOver(row => row.ProtectionGroup)
.Where(row => row.ProtectionGroupIdentifier.GroupGuid ==
protectionGroupIdentifier.GroupGuid)
.SingleOrDefault();
ProtectionGroupIdentifier.GroupGuid是Guid类型
GroupGuid是Guid Property。但是当我使用JoinQueryOver时,NHibernate不会计算它。当在GroupGuid实体(ProtectionGroupCheckpointStorageObject)上激活QueryOver时,Nhibernate提供正确的SQL和Guid类型的GroupGuid - [Type:Guid(0)] – Haimon 2012-07-08 19:16:05
看起来像NHibernate中的一个错误:当在两个表之间使用JoinQueryOver时,NHibernate无法转换simple Guid价值uniqueidentifier。需要你的建议。谢谢 – Haimon 2012-07-09 09:08:41
ProtectionGroupIdentifier是另一个实体还是自定义类型或组件?也许问题出在那。 – 2012-07-09 13:32:23