2

次のマッピングでロードしているオブジェクトに 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() を実行する方法はありますか?

ありがとう

ストゥ

4

1 に答える 1

1

それは不可能だと思います(まだ?)

NHibernate JIRA のこの機能要求/改善要求を参照してください。

于 2009-09-24T10:32:40.353 に答える