protected string GetLimitOffsetSelectQuery(AbstractQueryBuilder builder, DbCommand selectCommand, ref int paramIndex, int fromRowIndex, int toRowIndex) { StringBuilder commandText = new StringBuilder(); builder.GetSelectQuery(selectCommand, ref paramIndex, commandText, 0); string limitParameterName; var limitParam = builder.CreateIn32Parameter(toRowIndex - fromRowIndex + 1, ref paramIndex, out limitParameterName); selectCommand.Parameters.Add(limitParam); string offsetParameterName; var offsetParam = builder.CreateIn32Parameter(fromRowIndex, ref paramIndex, out offsetParameterName); selectCommand.Parameters.Add(offsetParam); commandText.Append("\nLIMIT ").Append(limitParameterName).Append(" OFFSET ").Append(offsetParameterName); return(commandText.ToString()); }
protected string GetFirstSkipQuery(AbstractQueryBuilder builder, DbCommand selectCommand, ref int paramIndex, int fromRowIndex, int toRowIndex) { StringBuilder commandText = new StringBuilder(); string firstParameterName; var firstParam = builder.CreateIn32Parameter(toRowIndex - fromRowIndex + 1, ref paramIndex, out firstParameterName); selectCommand.Parameters.Add(firstParam); string skipParameterName; var skipParam = builder.CreateIn32Parameter(fromRowIndex, ref paramIndex, out skipParameterName); selectCommand.Parameters.Add(skipParam); commandText.Append("SELECT FIRST ").Append(firstParameterName).Append(" SKIP ").Append(skipParameterName).Append(' '); builder.GetSelectQuery(selectCommand, ref paramIndex, commandText, 0, false); var query = commandText.ToString(); return(query); }