@@ -314,42 +314,31 @@ public override string Translate(SqlJoinMethod method)
314
314
} ;
315
315
}
316
316
317
- /// <inheritdoc/>
318
- public override void Translate ( SqlCompilerContext context , SqlSelect node , SelectSection section )
317
+ public override void SelectLimit ( SqlCompilerContext context , SqlSelect node ) =>
318
+ context . Output . AppendSpacePrefixed ( "TOP " ) ;
319
+
320
+ public override void SelectOffset ( SqlCompilerContext context , SqlSelect node ) => throw new NotSupportedException ( ) ;
321
+
322
+ public override void SelectExit ( SqlCompilerContext context , SqlSelect node )
319
323
{
320
324
var output = context . Output ;
321
- switch ( section ) {
322
- case SelectSection . Entry :
323
- base . Translate ( context , node , section ) ;
324
- break ;
325
- case SelectSection . Limit :
326
- _ = output . Append ( "TOP" ) ;
327
- break ;
328
- case SelectSection . Offset :
329
- throw new NotSupportedException ( ) ;
330
- case SelectSection . Exit :
331
- var hasHints = false ;
332
- foreach ( var hint in node . Hints ) {
333
- switch ( hint ) {
334
- case SqlForceJoinOrderHint :
335
- AppendHint ( output , "FORCE ORDER" , ref hasHints ) ;
336
- break ;
337
- case SqlFastFirstRowsHint sqlFastFirstRowsHint :
338
- AppendHint ( output , "FAST " , ref hasHints ) ;
339
- _ = output . Append ( sqlFastFirstRowsHint . Amount ) ;
340
- break ;
341
- case SqlNativeHint sqlNativeHint :
342
- AppendHint ( output , sqlNativeHint . HintText , ref hasHints ) ;
343
- break ;
344
- }
345
- }
346
- if ( hasHints ) {
347
- _ = output . Append ( ")" ) ;
348
- }
349
- break ;
350
- default :
351
- base . Translate ( context , node , section ) ;
352
- break ;
325
+ var hasHints = false ;
326
+ foreach ( var hint in node . Hints ) {
327
+ switch ( hint ) {
328
+ case SqlForceJoinOrderHint :
329
+ AppendHint ( output , "FORCE ORDER" , ref hasHints ) ;
330
+ break ;
331
+ case SqlFastFirstRowsHint sqlFastFirstRowsHint :
332
+ AppendHint ( output , "FAST " , ref hasHints ) ;
333
+ _ = output . Append ( sqlFastFirstRowsHint . Amount ) ;
334
+ break ;
335
+ case SqlNativeHint sqlNativeHint :
336
+ AppendHint ( output , sqlNativeHint . HintText , ref hasHints ) ;
337
+ break ;
338
+ }
339
+ }
340
+ if ( hasHints ) {
341
+ _ = output . Append ( ")" ) ;
353
342
}
354
343
355
344
static void AppendHint ( IOutput output , string hint , ref bool hasHints )
@@ -365,18 +354,8 @@ static void AppendHint(IOutput output, string hint, ref bool hasHints)
365
354
}
366
355
}
367
356
368
- /// <inheritdoc/>
369
- public override void Translate ( SqlCompilerContext context , SqlUpdate node , UpdateSection section )
370
- {
371
- switch ( section ) {
372
- case UpdateSection . Limit :
373
- _ = context . Output . Append ( "TOP" ) ;
374
- break ;
375
- default :
376
- base . Translate ( context , node , section ) ;
377
- break ;
378
- }
379
- }
357
+ public override void UpdateLimit ( SqlCompilerContext context ) =>
358
+ context . Output . AppendSpaceIfNecessary ( ) . Append ( "TOP" ) . AppendSpaceIfNecessary ( ) ;
380
359
381
360
/// <inheritdoc/>
382
361
public override void Translate ( SqlCompilerContext context , SqlDelete node , DeleteSection section )
@@ -677,19 +656,19 @@ protected virtual string GetCurentNameOfDefaultConstraintScript()
677
656
{
678
657
return @"DECLARE @{0} VARCHAR(256)
679
658
SELECT @{0} = {1}.sys.default_constraints.name
680
- FROM
659
+ FROM
681
660
{1}.sys.all_columns
682
661
INNER JOIN
683
662
{1}.sys.tables
684
663
ON all_columns.object_id = tables.object_id
685
- INNER JOIN
664
+ INNER JOIN
686
665
{1}.sys.schemas
687
- ON tables.schema_id = schemas.schema_id
666
+ ON tables.schema_id = schemas.schema_id
688
667
INNER JOIN
689
668
{1}.sys.default_constraints
690
669
ON all_columns.default_object_id = default_constraints.object_id
691
670
692
- WHERE
671
+ WHERE
693
672
schemas.name = '{2}'
694
673
AND tables.name = '{3}'
695
674
AND all_columns.name = '{4}'" ;
0 commit comments