2

私のアプリケーションは、Criterionオブジェクトを作成することにより、ユーザー入力に基づいて実行時に動的に生成されたクエリを作成します。

ICriterion criterion = Restrictions.Eq("Name", "John");
......
detachedCriteriaSomewhereElse.Add(criterion);

NHLambdaExtensionsでこれを行うにはどうすればよいですか?

私が本当にする必要があるのは

ICriterion criterion = Restrictions.Eq<Person>(p=>  p.Name == "John");

しかし、これは無効です。これを行う方法はありますか?

4

1 に答える 1

2

With the NHLambdaExtensions you have the SQLExpression class that lets you do the following:

ICriterion criterion = SqlExpression.CriterionFor<Person>(p => p.Name == "John");
于 2009-11-27T16:14:18.843 に答える