I have a mapping like this for a DateTime column:
...
Map(x => x.Created).Column("CREATED")
.Access.Property()
.CustomType<DateTime>()
.CustomSqlType("datetime")
.Not.Nullable();
...
In my code I define
outboxCriteria.Add(Restrictions.Eq("Created", startDate));
where ‘startDate’ is of type DateTime.
When looking at the created SQL I see for the above criteria
...
and Created = 2/14/2012 12:00:00 AM
...
which is not correct. I would expect NHibernate to create
...
and Created = '2/14/2012 12:00:00 AM'
...
I also observed that same problem with String types.
Map( x => x.ReceiverName).Column("UserName")
.CustomType("string")
.Access.Property()
.CustomSqlType("nvarchar(256)")
.Nullable()
.Length(256);
The resulting SQL does not put strings in quotes:
...
and UserName = Paul
...
instead of
...
and UserName = 'Paul'
...
The mapping works quite well except these problems.
What am I making wrong?
specifying
.CustomSqlType("nvarchar(256)")rendersLength()to a noop. Also string and datetime are no customeTypes/customSqlTypes. Maybe NHibernate is confused by them.Remove all but
Map( x => x.ReceiverName).Column("UserName").Length(256).