コード例 #1
0
 public void BuildCommandText(
     SqlContainer sqlContainer,
     SqlCommand sqlCommand,
     StringBuilder commandText,
     int pageSize,
     Sqls.TableTypes tableType,
     int?commandCount)
 {
     if (Count > 0)
     {
         commandText.Append(
             "order by ",
             this
             .GroupBy(o => o.ColumnBracket)
             .Select(o => o.FirstOrDefault())
             .Select(o => o.Sql(
                         sqlContainer: sqlContainer,
                         sqlCommand: sqlCommand,
                         tableBracket: Sqls.GetTableBracket(o.TableName),
                         tableType: tableType))
             .Join(),
             " ");
         if (pageSize != 0)
         {
             commandText.Append(
                 $"offset {Parameters.Parameter.SqlParameterPrefix}Offset", commandCount.ToString(),
                 $" rows fetch next {Parameters.Parameter.SqlParameterPrefix}PageSize", commandCount.ToString(),
                 " rows only ");
         }
     }
 }
コード例 #2
0
 public void BuildCommandText(
     SqlContainer sqlContainer,
     SqlCommand sqlCommand,
     StringBuilder commandText,
     int?commandCount,
     bool distinct,
     int top)
 {
     commandText.Append("select ");
     Build_DistinctClause(commandText, distinct);
     Build_TopClause(
         commandText: commandText,
         top: top);
     if (this.Any())
     {
         commandText.Append(this
                            .Select(o => o.CommandText(
                                        sqlContainer: sqlContainer,
                                        sqlCommand: sqlCommand,
                                        tableBracket: Sqls.GetTableBracket(o.TableName),
                                        commandCount: commandCount))
                            .Join(), " ");
     }
     else
     {
         commandText.Append("* ");
     }
     RemoveAll(o => o.AdHoc);
 }
コード例 #3
0
 public string Sql(
     ISqlObjectFactory factory,
     SqlContainer sqlContainer,
     ISqlCommand sqlCommand,
     int?commandCount,
     string multiClauseOperator = " and ",
     bool select = false)
 {
     if (!select)
     {
         this.Where(o => o?.ColumnBrackets != null)
         .ForEach(where => where.ColumnBrackets =
                      where.ColumnBrackets.Select(o => o.Split('.').Last()).ToArray());
     }
     return(this.Where(o => o != null).Any(o => o.Using)
         ? Clause + this
            .Where(o => o != null)
            .Where(o => o.Using)
            .Select(o => o.Sql(
                        factory: factory,
                        sqlContainer: sqlContainer,
                        sqlCommand: sqlCommand,
                        tableBracket: Sqls.GetTableBracket(o.TableName),
                        commandCount: commandCount,
                        select: select))
            .Join(multiClauseOperator) + " "
         : string.Empty);
 }
コード例 #4
0
 public void BuildCommandText(
     StringBuilder commandText,
     int pageSize,
     Sqls.TableTypes tableType,
     int?commandCount)
 {
     if (Count > 0)
     {
         commandText.Append(
             "order by ",
             this
             .GroupBy(o => o.ColumnBracket)
             .Select(o => o.FirstOrDefault())
             .Select(o => o.Sql(
                         tableBracket: Sqls.GetTableBracket(o.TableName),
                         tableType: tableType))
             .Join(),
             " ");
         if (pageSize != 0)
         {
             commandText.Append(
                 "offset @_Offset", commandCount.ToString(),
                 " rows fetch next @_PageSize", commandCount.ToString(),
                 " rows only ");
         }
     }
 }
コード例 #5
0
 public void BuildCommandText(StringBuilder commandText)
 {
     if (this.Any())
     {
         commandText.Append("group by ", this.Select(o =>
                                                     Sqls.TableAndColumnBracket(
                                                         tableBracket: Sqls.GetTableBracket(o.TableName),
                                                         columnBracket: o.ColumnBracket))
                            .Join(), " ");
     }
 }
コード例 #6
0
 public string Sql(
     SqlContainer sqlContainer,
     SqlCommand sqlCommand,
     int?commandCount)
 {
     return(this.Any(o => o.Using)
         ? Clause + this
            .Where(o => o.Using)
            .Select(o => o.Sql(
                        sqlContainer: sqlContainer,
                        sqlCommand: sqlCommand,
                        tableBracket: Sqls.GetTableBracket(o.TableName),
                        commandCount: commandCount))
            .Join(MultiClauseOperator) + " "
         : string.Empty);
 }