入力パラメータに応じて徐々にuppを構築するNHibernate基準に取り組んでいます。
これらのパラメータの郵便セクションで問題が発生しました。5桁の郵便番号を取得したため、入力パラメーターはintですが、データベースでは外部の郵便番号も受け入れるため、データベースはそれを文字列として保存します。
NHibernate Criteria / Criterionで複製しようとしているのは、次のwhere句です。
WHERE
11182 <=
(case when this_.SendInformation = 0 AND dbo.IsInteger(this_.Zipcode) = 1 then
CAST(REPLACE(this_.Zipcode, ' ', '') AS int)
when this_.SendInformation = 1 AND dbo.IsInteger(this_.WorkZipcode) = 1 then
CAST(REPLACE(this_.WorkZipcode, ' ', '') AS int)
when this_.SendInformation = 2 AND dbo.IsInteger(this_.InvoiceZipcode) = 1 then
CAST(REPLACE(this_.InvoiceZipcode, ' ', '') AS int)
else
NULL
end)
メンバーの連絡先(this_
)が情報の送信先を優先している場所を確認し、入力zipcodeを整数として3つの異なる列に対して確認します。これは、列がint(IsInteger(expr)
関数)に変換可能かどうかに応じて行われます。側面をマークしますNULL
この場合、郵便番号が> =入力パラメーター(パラメーターが最初であるためSQLコードで逆になっている)であるかどうかを確認するだけです。目標は、between('AND'ステートメントでラップされた2つの句)、>=または<=を実行することです。
アップデート
成功のヒントを得ました。
Projections.SqlProjection("(CASE when SendInformation = 0 AND dbo.IsInteger(Zipcode) = 1 then CAST(REPLACE(Zipcode, ' ', '') AS int) when SendInformation = 1 AND dbo.IsInteger(WorkZipcode) = 1 then CAST(REPLACE(WorkZipcode, ' ', '') AS int) when SendInformation = 2 AND dbo.IsInteger(InvoiceZipcode) = 1 then CAST(REPLACE(InvoiceZipcode, ' ', '') AS int) else NULL END)"
, new[] { "SendInformation", "Zipcode", "WorkZipcode", "InvoiceZipcode" },
new[] { NHibernateUtil.Int32, NHibernateUtil.String, NHibernateUtil.String, NHibernateUtil.String });
Projections.SqlProjectionに句全体をスローしますが、コードを実行すると、プロジェクションの一部が切り取られ( "AS int)else NULL END)"が最後から切り取られ、SQLが破損します。これには何らかの制限がありますか?