次のマッピングでロードしているオブジェクトに IDictionary があります。
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>
これは正常に動作し、Valuation オブジェクトには ValuationDate がありませんが、Nhibernate は必要に応じて ValuationDate をディクショナリのキーにロードしています。ValuationDate を指定して Valuation を 1 つだけ取得する InternalFund にクエリを実行したいと考えています。HQL の index() 関数を使用してこれを行うことができました。
"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 で index() を実行する方法はありますか?
ありがとう
ストゥ