OracleをDBとして使用しています。NHibernateのQueryOverで次の休止状態クエリを変換する方法。
string condition = "RepositoryItemDO.RepositoryType = :REPTYPE AND
24*(SYSDATE-RepositoryItemDO.FingerPrint.CreatingDateTime) >= :HOURS"
+ " AND RepositoryItemDO.TargetEncryption IS NOT NULL AND RepositoryItemDO.TargetStorage IS NOT NULL";
QueryOverで上記のクエリの構文を書く方法は?
VarArgsSQLFunctionを使用して、QueryOverで算術演算を使用できます。また、sysdateにアクセスするために、OracleDilectですでに定義されているNoArgSQLFunctionを使用できます。
以下は、queryoverを使用して試すことができるサンプルクエリです。
var func = Projections.SqlFunction(new VarArgsSQLFunction(NHibernateUtil.Double, "(", "-", ")"), NHibernateUtil.DateTime, Projections.SqlFunction("sysdate", NHibernateUtil.DateTime), Projections.Property<AdministrativeCaseEO>(c => c.EffectiveCasePeriod.EffectiveStartDate));
var parfunc = Projections.SqlFunction(new VarArgsSQLFunction(NHibernateUtil.Double, "(", "*", ")"), NHibernateUtil.Decimal, func, Projections.Constant(24));
var conjunction = Restrictions.Conjunction()
.Add(Restrictions.Eq(Projections.Property<RepositoryItemDO>(c => c.RepositoryType ), yourRefType))
.Add(Restrictions.IsNotNull(Projections.Property<RepositoryItemDO>(c => c.TargetEncryption)))
.Add(Restrictions.IsNotNull(Projections.Property<RepositoryItemDO>(c => c.TargetStorage)))
.Add(dateConj);
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加