NHibernate (できれば QueryOver 構文) を使用して次の SQL を取得するにはどうすればよいですか?
SELECT this_.Name as_, count(IsNull(this_.Name , 'UNKNOWN') ) as NameCount
FROM...
NHibernate (できれば QueryOver 構文) を使用して次の SQL を取得するにはどうすればよいですか?
SELECT this_.Name as_, count(IsNull(this_.Name , 'UNKNOWN') ) as NameCount
FROM...
IsNull は NHibernates sql 方言ではサポートされていませんが、Coalesce はサポートされており、2 つのパラメーターについては同じです。
できるよ
Projections.SqlFunction("Coalesce", NHibernateUtil.String,
Projections.Property("Name"), Projections.Constant("UNKNOWN"))
IsNull() と同等のプロジェクションを取得します。
ICriteriaにはNHibernate.Criterion.Restrictions.IsNull(PropertyName)
、QueryOverでも使用できると思います-
var qOver = QueryOver.Of<MyEntity>(() => meEntity);
qOver = qOver.Where(Restrictions.IsNull(PropertyName));