Context for generating SQL. This contains all the data that is build up when generating SQL for a Query
 internal override void BuildSql(BuildSqlContext sqlContext)
 {
     sqlContext.Builder.Append("[");
     sqlContext.Builder.Append(_tableName);
     sqlContext.Builder.Append("] ");
     sqlContext.Builder.Append(sqlContext.ResolveAlias(this));
 }
 internal override void BuildSql(BuildSqlContext context)
 {
     var parameterName = context.CreateNextParameterName();
     context.Parameters.Add(context.DataTool.CreateDateTimeParameter(parameterName, _value));
     context.Builder.Append("@");
     context.Builder.Append(parameterName);
 }
        internal override void BuildSql(BuildSqlContext sqlContext)
        {
            _left.BuildSql(sqlContext);
            sqlContext.Builder.Append(" LIKE ");

            int parameterNo = sqlContext.Parameters.Count + 1;
            string parameterName = "p" + parameterNo;
            sqlContext.Parameters.Add(sqlContext.DataTool.CreateStringParameter(parameterName, _name + "%", null));
            sqlContext.Builder.Append("@");
            sqlContext.Builder.Append(parameterName);
        }
 /// <summary>
 /// Builds the SQL for the full text.
 /// </summary>
 internal override void BuildSql(BuildSqlContext sqlContext)
 {
     sqlContext.Builder.Append("contains(");
     foreach (FieldReference reference in _fieldReferences)
     {
         reference.BuildSql(sqlContext);
         sqlContext.Builder.Append(",");
     }
     new StringConstant(_searchText).BuildSql(sqlContext);
     sqlContext.Builder.Append(")");
 }
Exemplo n.º 5
0
 internal override void BuildSql(BuildSqlContext sqlContext)
 {
     Left.BuildSql(sqlContext);
     var builder = sqlContext.Builder;
     switch (_joinType)
     {
         case JoinType.Left:
             builder.Append(" left outer join ");
             break;
         case JoinType.Inner:
             builder.Append(" inner join ");
             break;
         default:
             throw new InvalidOperationException("Unknown join type");
     }
     Right.BuildSql(sqlContext);
     if (_wherePart == null)
         return;
     builder.Append(" on ");
     _wherePart.BuildSql(sqlContext);
 }
 /// <summary>
 /// Builds the SQL for the operator.
 /// </summary>
 internal override void BuildSql(BuildSqlContext context)
 {
     var activeParts = new List<WherePart>(ActiveParts);
     if (activeParts.Count == 0)
         return;
     if (activeParts.Count == 1)
     {
         activeParts[0].BuildSql(context);
         return;
     }
     bool afterFirst = false;
     context.Builder.Append("(");
     foreach (var part in activeParts)
     {
         if (afterFirst)
         {
             context.Builder.Append(" ");
             context.Builder.Append(_operatorName);
             context.Builder.Append(" ");
         }
         part.BuildSql(context);
         afterFirst = true;
     }
     context.Builder.Append(")");
 }
 internal override ParseResult Parse(DataTool dataTool)
 {
     IList<IDataParameter> parameters = new List<IDataParameter>();
     var builder = new StringBuilder();
     builder.Append("select ");
     WriteSelectedColumns(builder);
     builder.Append(" from ");
     var secondTable = false;
     var buildSqlContext = new BuildSqlContext(builder, dataTool, parameters, GetAlias);
     foreach (var table in _tables)
     {
         if (secondTable)
             builder.Append(", ");
         table.BuildSql(buildSqlContext);
         secondTable = true;
     }
     if (_whereClause.Active)
     {
         builder.Append(" where ");
         _whereClause.BuildSql(buildSqlContext);
     }
     if (_sortExpressions.Count > 0)
     {
         builder.Append(" order by ");
         var first = true;
         foreach (var sortExpression in _sortExpressions)
         {
             if (!first)
                 builder.Append(", ");
             first = false;
             sortExpression.Field.BuildSql(buildSqlContext);
         }
     }
     return new ParseResult(builder.ToString(), parameters);
 }
 /// <summary>
 /// Builds the SQL for this field reference.
 /// </summary>
 internal override void BuildSql(BuildSqlContext context)
 {
     context.Builder.Append(context.ResolveAlias(_table));
     context.Builder.Append(".[");
     context.Builder.Append(_fieldName);
     context.Builder.Append("]");
 }
 internal abstract void BuildSql(BuildSqlContext sqlContext);
 internal override void BuildSql(BuildSqlContext sqlContext)
 {
     _left.BuildSql(sqlContext);
     sqlContext.Builder.Append(" < ");
     _right.BuildSql(sqlContext);
 }