在我的对象图中, VendorServiceRateChange 有一个延迟加载的属性IList<VendorService>
VendorServiceList ,而 VendorService 有一个延迟加载的属性IList<ClientService>
。
当我运行以下代码时,我在 VendorServiceList 和 ClientServiceList 之间得到一个笛卡尔积。
queueList = session
.CreateCriteria<VendorRateChange>()
.Add(Restrictions.IsNull("ProcessedDate"))
.Add(Restrictions.Le("EffectiveDate", DateTime.Now))
.SetFetchMode("VendorServiceList", FetchMode.Join)
.SetFetchMode("VendorServiceList.Vendor", FetchMode.Join)
.SetFetchMode("VendorServiceList.CityService", FetchMode.Join)
.SetFetchMode("VendorServiceList.ClientServices", FetchMode.Join)
.SetResultTransformer(new DistinctRootEntityResultTransformer())
.AddOrder(new Order("Audit.CreatedDate", true))
.List<VendorRateChange>();
有没有办法使用 Criteria 或 DetachedCriteria 来构造这个查询,这不会导致笛卡尔积作为我的 VendorServiceList?我不想诉诸于注释掉“VendorServiceList.ClientServices”上的获取并在初始查询返回后使用 Initialize 调用循环。
提前致谢。