Criteria を使用して次の機能を実行しようとしていますが、SQL のエラーを示す実行時エラーが発生します。
var query = session.CreateCriteria<TableName>()
.Add(Restrictions.Disjunction()
.Add(Restrictions.InsensitiveLike("Property1", keyword, MatchMode.Anywhere))
.Add(Restrictions.InsensitiveLike("Property2", keyword, MatchMode.Anywhere)));
query.SetProjection(Projections.Count(Projections.Distinct(
Projections.ProjectionList()
.Add(Projections.Property("Property1"))
.Add(Projections.Property("Property3"))
)));
テーブル マッピングは次のようになります。
public class TableName
{
public int Property1 {get;set;}
public int Property2 {get;set;}
public int Property3 {get;set;}
public int Property4 {get;set;}
}
予測に基づいて個別の結果をカウントする必要があります。結果を行全体としてカウントしたくありません。
誰でもこれで私を助けてもらえますか?
- - - - - アップデート - - - - -
これは私が達成しようとしていることです:
select Count(*)
from
(
select distinct Property1 , Property2
from tableName
where Property1 like '%t%' or Property3 like '%t%'
) As x