在QueryOver中转换+连接

时间:2011-05-27 11:19:57

标签: nhibernate fluent-nhibernate queryover

我不能完全理解这一点,但我有点困惑,因为它根本没有进行连接:

ActualBookingOccupancy abo2Alias = null;
AccommodationUnit auAlias = null;

List<ActualBookingOccupancy> sectorList = (List<ActualBookingOccupancy>)Session.QueryOver<ActualBooking>()
.JoinAlias(x => x.AccommodationUnit, () => auAlias)
.Where(x => (x.AccommodationUnit.AccommodationUnitID != id)
    && (x.YearMonth >= start && x.YearMonth < end)
    && auAlias.Rating == au.Rating)
.SelectList(x => x
   .SelectGroup(xx => xx.YearMonth).WithAlias(() => abo2Alias.YearMonth)
   .SelectSum(xx => xx.RoomOccupancy).WithAlias(() => abo2Alias.ProviderOccupancy))
.TransformUsing(Transformers.AliasToBean<ActualBookingOccupancy>())
.List<ActualBookingOccupancy>();

我只是尝试将ActualBooking加入AccommodationUnit,但使用SQL分析器的基础请求显示它甚至没有尝试此连接,而是使用未解析的别名。但是,我的映射显示正确:

CompositeId()
   .KeyProperty(x => x.YearMonth)
   .KeyProperty(x => x.RoomType)
   .KeyReference(x => x.AccommodationUnit, "AccommodationUnitID");

可能是因为我使用的是复合键,这实际上可能是FluentNHibernate中的一个错误?

0 个答案:

没有答案