public BuildSqlContext(
			StringBuilder builder,
			DataTool dataTool,
			IList<IDataParameter> parameters,
			Func<QueryTable, string> resolveAlias)
        {
            _builder = builder;
            _dataTool = dataTool;
            _parameters = parameters;
            _resolveAlias = resolveAlias;
        }
 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);
 }
Пример #3
0
 internal abstract ParseResult Parse(DataTool dataTool);
 public void Setup()
 {
     _dataToolMock = new Mock<DataTool>();
     _dataToolMock.CallBase = true;
     _dataTool = _dataToolMock.Object;
 }