You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
using Connected.Expressions;
|
|
using Connected.Expressions.Languages;
|
|
using Connected.Expressions.Translation;
|
|
using Connected.Expressions.Translation.Rewriters;
|
|
using System.Linq.Expressions;
|
|
|
|
namespace Connected.Data.Sql;
|
|
|
|
internal sealed class TSqlLinguist : Linguist
|
|
{
|
|
|
|
public TSqlLinguist(ExpressionCompilationContext context, TSqlLanguage language, Translator translator)
|
|
: base(context, language, translator)
|
|
{
|
|
}
|
|
|
|
public override Expression Translate(Expression expression)
|
|
{
|
|
/*
|
|
* fix up any order-by's
|
|
*/
|
|
expression = OrderByRewriter.Rewrite(Language, expression);
|
|
|
|
expression = base.Translate(expression);
|
|
/*
|
|
* convert skip/take info into RowNumber pattern
|
|
*/
|
|
expression = SkipToRowNumberRewriter.Rewrite(Language, expression);
|
|
/*
|
|
* fix up any order-by's we may have changed
|
|
*/
|
|
expression = OrderByRewriter.Rewrite(Language, expression);
|
|
|
|
return expression;
|
|
}
|
|
|
|
public override string Format(Expression expression)
|
|
{
|
|
return TSqlFormatter.Format(Context, expression, Language);
|
|
}
|
|
}
|