0

I recently got an exception from NHibernate when trying to access the Date property of a DateTimeOffset property.

var v1 = nhSession.Query<MyType>.Where(o => o.DateTimeOffsetProperty.Date == DateTimeOffset.Now.Date).ToList();

I would have thought this would have "just worked." What is the best solution to this problem?

Becca Dee
  • 1,530
  • 1
  • 24
  • 51

1 Answers1

2

I created an HQL generator that does the following in BuildHql:

return p_treeBuilder.MethodCall(
    "date"
  , new HqlExpression[] { (HqlExpression) p_visitor.Visit(p_expression) }
);

This seems to be working, but I'd like to know if this is already built in and I missed it. Thanks!

Becca Dee
  • 1,530
  • 1
  • 24
  • 51
  • From what I can see, only the properties of `DateTime` have been considered so far (`DateTimePropertiesHqlGenerator`). Please open a Jira issue to get that added for `DateTimeOffset`. – Diego Mijelshon Jul 10 '12 at 00:43