2
我有一個IDictionary的對象,我加載與下面的映射上:(獨立屋)標準等效HQL的「索引」功能
public class InternalFund : IInternalFund
{
public virtual IDictionary<DateTime, IValuation> Valuations { get; set; }
}
<class name="InternalFund">
<map name="Valuations">
<key>
<column name="FundID" />
</key>
<index type="DateTime" column="ValuationDate" />
<one-to-many class="Echo.EchoDomain.Portfolio.Valuation" />
</map>
</class>
這工作得很好,估價對象不具有ValuationDate,但Nhibernate會根據需要將ValuationDate加載到字典的關鍵字中。我想查詢InternalFund檢索指定ValuationDate的一個估價。我已經成功地做到這一點使用的HQL指數()函數:
"from InternalFund i left join fetch i.Valuations v where index(v)='2009-09-30'"
再次,這更是別出心裁,正是我想做產生以下WHERE子句:
((valuations1_.ValuationDate='2009-09-30'))
,不過我真的喜歡在DetachedCriteria中做到這一點,以保持我的項目的完整性。當我嘗試
.Add(Restrictions.Eq("index(Valuations)", valuationDate));
或者
.CreateAlias("Valuations", "v", JoinType.LeftOuterJoin)
.Add(Restrictions.Eq("index(v)", valuationDate));
它說:
QueryException: could not resolve property: index(v) of: Echo.EchoDomain.Fund.InternalFund
有沒有一種方法來運行一個的DetachedCriteria指數()?
感謝
斯圖