Hi, I have a problem with Projections.Conditional.

The following statement

IProjection isError = Projections.Conditional( Restrictions.Eq
( "event.LogLevel", eLogLevel.Fatal.ToString( ) ), Projections.Constant
( 1 ), Projections.Constant( 0 ) );

ProjectionList fields = Projections.ProjectionList( )
    .Add( LambdaProjection.Property<LogEvent>( logEvent =>
logEvent.ApplID ), "ApplID" )
    .Add( LambdaProjection.CountDistinct<LogEvent>( logEvent =>
logEvent.Id ), "TotalCount" )
    .Add( Projections.Sum( isError ), "ErrorCount" )
    .Add( LambdaProjection.GroupProperty<LogEvent>( logEvent =>
logEvent.ApplID ) );

ICriteria criteria = Session.CreateCriteria( typeof( LogEvent ),
"event" )
    .Add<LogEvent>( p => p.ApplID == "LogEventViewer" )
    .SetProjection( fields );

creates a wrong sql statement:

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'

The "case when" statement is incomplete and the order of the
parameters is wrong.

Any idea how to solve this problem?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to