Nhibernate QueryOver:如何引用映射组件中的属性

时间:2013-05-07 18:18:17

标签: nhibernate

我们有一个像这样映射的组件:

Map(x => x.EffectiveDates)
.Columns
.Add(new[] { "EffDt", "ExpDt" })
.CustomType(typeof(DateRangeUserType));

我想做这样的事情

_session
.QueryOver<Agreement>()
.Where(a => a.EffectiveDates.Start >= now 
         && a.EffectiveDates.End <= now)

但我不能。它失败并出现错误

  

无法解析属性:EffectiveDates.Start

如何通过QueryOver实现这一目标?

1 个答案:

答案 0 :(得分:0)

由于在映射中使用了CustomType,因此失败。如果它只是作为组件映射,那么它可以正常工作。

 Component(x => x.EffectiveDates, m =>
        {
             m.Map(x => x.Start, "EffDt");
             m.Map(x => x.End, "ExpDt");
        });
相关问题