Class DefaultQuerySqlGenerator
Default sql query visitor for generating SELECT command.
Inheritance
Implements
Namespace: Kros.KORM.Query.Sql
Assembly: Kros.KORM.dll
Syntax
public class DefaultQuerySqlGenerator : ExpressionVisitor, ISqlExpressionVisitor
Constructors
DefaultQuerySqlGenerator(IDatabaseMapper)
Constructor.
Declaration
public DefaultQuerySqlGenerator(IDatabaseMapper databaseMapper)
Parameters
Type | Name | Description |
---|---|---|
IDatabaseMapper | databaseMapper | Database mapper. |
Properties
DatabaseMapper
Gets the database mapper.
Declaration
protected IDatabaseMapper DatabaseMapper { get; }
Property Value
Type | Description |
---|---|
IDatabaseMapper |
LinqParameters
Gets the linq query parameters.
Declaration
protected DefaultQuerySqlGenerator.Parameters LinqParameters { get; }
Property Value
Type | Description |
---|---|
DefaultQuerySqlGenerator.Parameters |
LinqStringBuilder
Gets the linq string builder.
Declaration
protected StringBuilder LinqStringBuilder { get; }
Property Value
Type | Description |
---|---|
System.Text.StringBuilder |
SelectExpression
Get root select expression.
Declaration
protected SelectExpression SelectExpression { get; }
Property Value
Type | Description |
---|---|
SelectExpression |
Methods
BindAnyCondition(String)
Adds any method to query.
Declaration
protected virtual string BindAnyCondition(string existsCondition)
Parameters
Type | Name | Description |
---|---|---|
System.String | existsCondition |
Returns
Type | Description |
---|---|
System.String |
BindContains(MethodCallExpression)
Binds the System.String.Contains(System.String) method.
Declaration
protected virtual Expression BindContains(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
BindEndWith(MethodCallExpression)
Binds the System.String.EndsWith(System.String) method.
Declaration
protected virtual Expression BindEndWith(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
BindIsNullOrEmpty(MethodCallExpression)
Binds the System.String.IsNullOrEmpty(System.String) method.
Declaration
protected virtual Expression BindIsNullOrEmpty(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
BindReplace(MethodCallExpression)
Binds the System.String.Replace(System.String,System.String) method.
Declaration
protected virtual Expression BindReplace(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
BindStartWith(MethodCallExpression)
Binds the System.String.StartsWith(System.String) method.
Declaration
protected virtual Expression BindStartWith(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
BindSubstring(MethodCallExpression)
Binds the System.String.Substring(System.Int32) method.
Declaration
protected virtual Expression BindSubstring(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
BindToLower(MethodCallExpression)
Binds to System.String.ToLower method.
Declaration
protected virtual Expression BindToLower(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
BindToUpper(MethodCallExpression)
Binds to System.String.ToUpper method.
Declaration
protected virtual Expression BindToUpper(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
BindTrim(MethodCallExpression)
Binds the System.String.Trim method.
Declaration
protected virtual Expression BindTrim(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
GenerateSql(Expression)
Generates the SQL from expression.
Declaration
public virtual string GenerateSql(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression. |
Returns
Type | Description |
---|---|
System.String | SQL select command text. |
GetOperator(BinaryExpression)
Gets the operator.
Declaration
protected virtual string GetOperator(BinaryExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.BinaryExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.String |
Visit(Expression)
Dispatches the expression to one of the more specialized visit methods in this class.
Declaration
public override Expression Visit(Expression node)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | node | The expression to visit. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | The modified expression, if it or any subexpression was modified; otherwise, returns the original expression. |
Overrides
VisitAggregate(MethodCallExpression, String)
Visits the Linq aggregate methods.
Declaration
protected virtual Expression VisitAggregate(MethodCallExpression expression, string aggregateName)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
System.String | aggregateName | Name of aggreage method. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
VisitAny(MethodCallExpression)
Visits the Linq Any method.
Declaration
protected virtual Expression VisitAny(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
VisitBinary(BinaryExpression)
Visits the Linq Binary.
Declaration
protected override Expression VisitBinary(BinaryExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.BinaryExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | If this binary expression is not supported. |
VisitColumns(ColumnsExpression)
Visits the columns.
Declaration
public virtual Expression VisitColumns(ColumnsExpression columnExpression)
Parameters
Type | Name | Description |
---|---|---|
ColumnsExpression | columnExpression | The column expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Expression |
VisitCompare(MethodCallExpression, ExpressionType)
Visit Visual Basic Compare expression
Declaration
protected virtual Expression VisitCompare(MethodCallExpression expression, ExpressionType binExpNodeType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | Method call expression Compare expression |
System.Linq.Expressions.ExpressionType | binExpNodeType | Binary expression node type |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Reduced expression. |
VisitConstant(ConstantExpression)
Visits the constant.
Declaration
protected override Expression VisitConstant(ConstantExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ConstantExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | If type of constant is System.Object. |
VisitCount(MethodCallExpression)
Visits the Linq Count method.
Declaration
protected virtual Expression VisitCount(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
VisitFirst(MethodCallExpression)
Visits the Linq First.
Declaration
protected virtual Expression VisitFirst(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
VisitGroupBy(GroupByExpression)
Visits the group by.
Declaration
public virtual Expression VisitGroupBy(GroupByExpression groupByExpression)
Parameters
Type | Name | Description |
---|---|---|
GroupByExpression | groupByExpression | The group by expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Expression |
VisitLinqExpression(MethodCallExpression)
Visits the linq expression.
Declaration
protected virtual Expression VisitLinqExpression(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The method call expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Reduced expression. |
VisitMember(MemberExpression)
Visits the member.
Declaration
protected override Expression VisitMember(MemberExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MemberExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | If the member type is not supported. |
VisitMethodCall(MethodCallExpression)
Visits the method call.
Declaration
protected override Expression VisitMethodCall(MethodCallExpression m)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | m | The method call expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Reuced expression |
Overrides
VisitOrderBy(OrderByExpression)
Visits the order by.
Declaration
public virtual Expression VisitOrderBy(OrderByExpression orderByExpression)
Parameters
Type | Name | Description |
---|---|---|
OrderByExpression | orderByExpression | The order by expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Expression |
VisitSelect(SelectExpression)
Visits the select.
Declaration
public virtual Expression VisitSelect(SelectExpression selectExpression)
Parameters
Type | Name | Description |
---|---|---|
SelectExpression | selectExpression | The select expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Expression |
VisitSql(SqlExpression)
Visits the SQL.
Declaration
public virtual Expression VisitSql(SqlExpression sqlExpression)
Parameters
Type | Name | Description |
---|---|---|
SqlExpression | sqlExpression | The SQL expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Expression |
VisitStringMethods(MethodCallExpression)
Visits the string methods.
Declaration
protected virtual Expression VisitStringMethods(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | If this System.String method is not supported. |
VisitTable(TableExpression)
Visits the table.
Declaration
public virtual Expression VisitTable(TableExpression tableExpression)
Parameters
Type | Name | Description |
---|---|---|
TableExpression | tableExpression | The table expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Expression |
VisitTake(MethodCallExpression)
Visits the Linq Take method.
Declaration
protected virtual Expression VisitTake(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | If call of Take method is not supported. |
VisitUnary(UnaryExpression)
Visits the unary.
Declaration
protected override Expression VisitUnary(UnaryExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.UnaryExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | If this unary expression is not supported. |
VisitVbOperatorsMethods(MethodCallExpression, ExpressionType)
Visit Visual Basic operators expressions.
Declaration
protected virtual Expression VisitVbOperatorsMethods(MethodCallExpression expression, ExpressionType binExpNodeType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | Method call expression |
System.Linq.Expressions.ExpressionType | binExpNodeType | Binary expression node type |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Reduced expression. |
VisitWhere(WhereExpression)
Visits the where.
Declaration
public virtual Expression VisitWhere(WhereExpression whereExpression)
Parameters
Type | Name | Description |
---|---|---|
WhereExpression | whereExpression | The where expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Expression |
VisitWhere(MethodCallExpression)
Visits the Linq Where method.
Declaration
protected virtual Expression VisitWhere(MethodCallExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.MethodCallExpression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression |