File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
src/EntityFramework6.Npgsql/SqlGenerators Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -829,6 +829,23 @@ protected string GetDbType(EdmType edmType)
829829
830830 public override VisitedExpression Visit ( [ NotNull ] DbCaseExpression expression )
831831 {
832+ // Check for COALESCE like CASE
833+ if ( expression . When . Count == 1 &&
834+ expression . When [ 0 ] . ExpressionKind == DbExpressionKind . IsNull )
835+ {
836+ var is_null = expression . When [ 0 ] as DbIsNullExpression ;
837+ if ( is_null . Argument . Equals ( expression . Else ) )
838+ {
839+ LiteralExpression coalesceExpression = new LiteralExpression ( " COALESCE( " ) ;
840+ coalesceExpression . Append ( expression . Else . Accept ( this ) ) ;
841+ coalesceExpression . Append ( "," ) ;
842+ coalesceExpression . Append ( expression . Then [ 0 ] . Accept ( this ) ) ;
843+ coalesceExpression . Append ( ") " ) ;
844+ return coalesceExpression ;
845+ }
846+ }
847+
848+ // General CASE
832849 var caseExpression = new LiteralExpression ( " CASE " ) ;
833850 for ( var i = 0 ; i < expression . When . Count && i < expression . Then . Count ; ++ i )
834851 {
You can’t perform that action at this time.
0 commit comments