public override DbCommand CreateSelectRangeCommand(WhereClip where, string[] columns, int topCount, int skipCount, string identyColumn, bool identyColumnIsNumber) { Check.Require(((object)where) != null && where.From != null, "expr and expr.From could not be null!"); Check.Require(columns != null && columns.Length > 0, "columns could not be null or empty!"); Check.Require(topCount > 0, "topCount must > 0!"); if (string.IsNullOrEmpty(where.OrderBy) && identyColumn != null) { where.SetOrderBy(new KeyValuePair<string,bool>[] { new KeyValuePair<string,bool>(identyColumn, false) }); } if (topCount == int.MaxValue && skipCount == 0) { return CreateSelectCommand(where, columns); } else if (skipCount == 0) { return CreateSelectTopCommand(where, columns, topCount); } else { Check.Require(!string.IsNullOrEmpty(identyColumn), "identyColumn could not be null or empty!"); identyColumn = ColumnFormatter.ValidColumnName(identyColumn); if (identyColumnIsNumber && where.OrderByStartsWith(identyColumn) && (string.IsNullOrEmpty(where.GroupBy) || where.GroupBy == identyColumn)) { return CreateSelectRangeCommandForSortedRows(where, columns, topCount, skipCount, identyColumn, where.OrderByStartsWith(identyColumn + " DESC")); } else { return CreateSelectRangeCommandForUnsortedRows(where, columns, topCount, skipCount, identyColumn); } } }
public override DbCommand CreateSelectRangeCommand(WhereClip where, string[] columns, int topCount, int skipCount, string identyColumn, bool identyColumnIsNumber) { //Check.Require(((object)where) != null && where.From != null, "expr and expr.From could not be null!"); //Check.Require(columns != null && columns.Length > 0, "columns could not be null or empty!"); //Check.Require(topCount > 0, "topCount must > 0!"); if (string.IsNullOrEmpty(where.OrderBy) && identyColumn != null) { where.SetOrderBy(new KeyValuePair <string, bool>[] { new KeyValuePair <string, bool>(identyColumn, false) }); } if (topCount == int.MaxValue && skipCount == 0) { return(CreateSelectCommand(where, columns)); } else if (skipCount == 0) { return(CreateSelectTopCommand(where, columns, topCount)); } else { //Check.Require(!string.IsNullOrEmpty(identyColumn), "identyColumn could not be null or empty!"); identyColumn = ColumnFormatter.ValidColumnName(identyColumn); if (identyColumnIsNumber && where.OrderByStartsWith(identyColumn) && (string.IsNullOrEmpty(where.GroupBy) || where.GroupBy == identyColumn)) { return(CreateSelectRangeCommandForSortedRows(where, columns, topCount, skipCount, identyColumn, where.OrderByStartsWith(identyColumn + " DESC"))); } else { return(CreateSelectRangeCommandForUnsortedRows(where, columns, topCount, skipCount, identyColumn)); } } }