I’m trying to retrieve a row using a where clause against a DateTime.
Note: Query is an IQueryable from ISession.Query extension.
var results = Query
.Where(row => row.TimeStampUtc == timeStampUtc);
This returns no results.
var results = Query.ToList()
.Where(row => row.TimeStampUtc == timeStampUtc);
This returns results. (By using ToList() im avoiding the NHibernate query provider).
What trick am I missing?
Update:
SQL profiler tells me that its querying for
where row.TimeStampUtc = '2011-01-28T09:28:55.00' /* @p0 */
but the actual column value is '2011-01-28 09:28:55.987' hence no matches.
Somewhere during mapping (presumably reading) I am losing the sub-second data.
The problem was caused by the fact the column was used as part of a
CompositeId.I could not use
CustomTypeon the column alone, because its ignored if the column is also defined as part of aCompositeId.The solution is the use the
Typemethod on theKeyPropertydefinition.