public int Count(SearchRequest <Tm> searchRequest) { var where = this.CombinWhere(searchRequest.AutoWhere(), searchRequest.ManualWhere()); var sql = string.Format("select count(0) as count from [{0}] {1}{2}", TableMapper.TableName, TableMapper.ShortTableName, where); return(this.Query <int>(sql)); }
public List <Te> SearchRequest(SearchRequest <Tm> searchRequest) { if (searchRequest.PageSize == 0) { searchRequest.PageSize = 10; } var where = this.CombinWhere(searchRequest.AutoWhere(), searchRequest.ManualWhere()); var sql = string.Format("select{0} {1} from [{2}] {3}{4}", searchRequest.PageSize < 0 ? "" : $" top {searchRequest.PageSize}", TableMapper.SelectFileds, TableMapper.TableName, TableMapper.ShortTableName, where); if (!string.IsNullOrEmpty(searchRequest.OrderBy)) { sql += " order by " + searchRequest.OrderBy; } return(this.Querys <Te>(sql)); }