누구든지 Projections.Conditional을 사용하여 "case ... when ..."과 같은 것을 생성하는 방법을 알고 있습니다.투영법. 조건 - 어떻게 사용합니까?
다음 코드는 잘못된 쿼리를 제공합니다.
IProjection isError = Projections.Conditional(Expression.Eq("event.LogLevel", eLogLevel.Fatal.ToString()), Projections.Constant(1), Projections.Constant(0));
ICriteria criteria = Session.CreateCriteria(typeof(LogEvent), "event")
.Add(Restrictions.Eq("event.ApplID", "LogEventViewer"))
.SetProjection(Projections.ProjectionList()
.Add(Projections.GroupProperty("event.ApplID"))
.Add(Projections.RowCount(), "TotalCount")
.Add(Projections.Sum(isError), "ErrorCount")
);
생성 된 문이 불완전하고 순서 매개 변수가 잘못되었습니다.
exec sp_executesql N'
SELECT this_.strApplID as y0_
, count(distinct this_.lngLogEventID) as y1_
, sum((case when this_.strLogLevel = ? then ? else ? end)) as y2_
, this_.strApplID as y3_
FROM qryLogEvent this_
WHERE this_.strApplID = @p0
GROUP BY this_.strApplID'
,N'@p0 nvarchar(5),@p1 int,@p2 int,@p3 nvarchar(14)'
,@p0=N'Fatal',@p1=1,@p2=0,@p3=N'LogEventViewer'
투영법을 사용하는 올바른 방법은 무엇입니까?
: 즉,이 문제가 해결 되었어야하지만, 여기 desribed로 순서를 망쳐 놨어요. 나는 모든 종류의 방식으로 시도해 왔으며, 매개 변수의 순서가 뒤죽박죽이다. NH의 어떤 버전을 사용하고 있습니까? – asgerhallas