I am using Fluent NHibernate on sqlserverce.
Using NHibernate QueryOver I try to retrieve a row – NHibernate generate automatically a a join query
and I get the following Exception:
[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 ]
From what I see, it seems that it tries to convert the value – 11111111-1111-1111-1111-111111111111 to numeric but this value is a Guid field:
CheckpointToProtectionGroup checkpointToProtectionGroup = Session
.QueryOver<CheckpointToProtectionGroup>()
.JoinQueryOver( row => row.ProtectionGroup)
.Where(row => row.ProtectionGroupIdentifier.GroupGuid ==
protectionGroupIdentifier.GroupGuid)
.SingleOrDefault();
ProtectionGroupIdentifier.GroupGuid is of Guid type
Looks like your
GroupGuidvalue is not correctly converted to SQL. It should have single quotes around the value.SQL Server tried to convert left hand value from
uniqueidentifier(Guid) tonumeric, since the right hand value isnumericvalue – numeric subtract operation with few operands.You have
protectionGroupIdentifier.GroupGuidvalue inWherepart of your QueryOver expression. Check ifGroupGuidis indeedGuidproperty. If it’s anobjectproperty, cast it toGuid.