/// <summary> /// Partitions the elements of a list around a given pivot element. The range to partition is [<paramref name="begin"/>, <paramref name="end"/>), and this range must be at least 2 elements long. /// </summary> /// <typeparam name="T">The type of items in the list.</typeparam> /// <param name="parameters">The source list, comparison object, and other lists that must be kept in sync.</param> /// <param name="begin">The beginning of the range to partition.</param> /// <param name="end">The ending of the range to partition.</param> /// <param name="pivotIndex">The index of the element chosen as the pivot.</param> /// <returns>The new index of the pivot element.</returns> private static int QuickSortPartition <T>(SortParameters <T> parameters, int begin, int end, int pivotIndex) { T pivotValue = parameters.List[pivotIndex]; // Move the pivot value to the end of the list temporarily parameters.Swap(pivotIndex, end - 1); // Make our way through the list (except the pivot value at the end), moving each element less than the pivot int storeIndex = begin; for (int i = begin; i != end - 1; ++i) { if (parameters.Comparer.Compare(parameters.List[i], pivotValue) < 0) { parameters.Swap(i, storeIndex); ++storeIndex; } } // Move pivot back to its proper place parameters.Swap(storeIndex, end - 1); // Return the new index of the pivot element return(storeIndex); }
public async Task <WrappedResponse <IEnumerable <PaymentRequest> > > SelectPaymentRequests ( string searchColumn, string prefix, string sortColumn, bool descendingOrder ) { var searchParameters = new SearchParameters { Column = searchColumn, Prefix = prefix }; var sortParameters = new SortParameters { Column = sortColumn, DescendingOrder = descendingOrder }; var response = await paymentRepository.SelectPaymentRequestsAsync(searchParameters, sortParameters) .ConfigureAwait(false); return(WrappedResponse <IEnumerable <PaymentRequest> > .Success(response)); }
/// <summary> /// 添加排序列名参数 /// Add by Jason.Song on 2018/10/18 /// </summary> /// <param name="name">待排序的列名</param> /// <param name="sort">排序类型</param> public void AddSortParameter(string name, SortType sort) { if (!SortParameters.ContainsKey(name)) { SortParameters.Add(name, sort); } }
public void SortText_Desc_SortDesc() { //Given RegExProvider.Setup(x => x.GetMatches(It.IsAny <string>(), It.IsAny <string>())).Returns(new List <string>() { "1", "2", "3" }); var parameters = new SortParameters() { Asc = false, SortOptions = SortOptions.AlphabeticOrder, Text = "Text" }; //When SortTextModel result = SortService.SortText(parameters); //Then Assert.IsNotNull(result); Assert.AreEqual(3, result.SortedText.Count()); Assert.AreEqual("3", result.SortedText.First()); Assert.AreEqual("2", result.SortedText.ElementAt(1)); Assert.AreEqual("1", result.SortedText.Last()); }
/// <summary> /// 煤车篷布资讯 /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="id"></param> /// <returns></returns> public ActionResult Index(int pageIndex = 1, int pageSize = 5, int?id = 0) { ViewData["pageIndex"] = pageIndex; ViewData["pageSize"] = pageSize; ViewData["total"] = 0; int totalcount = 0; List <newst> list = new List <newst>(); // list = newsbll.getall(); StringBuilder where = new StringBuilder(); where.Append(" and del =1"); SortParameter sa = new SortParameter(); sa.Field = "creationtime"; sa.Direction = SortDirection.DESC; SortParameters ot = new SortParameters(); ot.Add(sa); list = newsbll.GetPage(out totalcount, pageIndex, pageSize, where.ToString(), "", ot); ViewData["total"] = totalcount; return(View(list)); }
public int Compare(object x, object y) { if (mOrder == SortOrder.None) { return(0); } ListViewItem lvix = (ListViewItem)x; ListViewItem lviy = (ListViewItem)y; string sx = lvix.SubItems[mColumn].Text; string sy = lviy.SubItems[mColumn].Text; SortParameters sort_params = null; int compare_result = 0; if (!mSorters.TryGetValue(mColumn, out sort_params)) { compare_result = CaseInsensitiveComparer.Default.Compare(sx, sy); } else { if (sort_params.Converter != null) { sx = sort_params.Converter.Convert(sx); sy = sort_params.Converter.Convert(sy); } compare_result = sort_params.Comparer.Compare(sx, sy); } return((mOrder == SortOrder.Ascending) ? compare_result : (-compare_result)); }
public async Task Projects_SortProjectsByName_Succeeds() { var groupShareClient = Helper.GsClient; var sortParameters = new SortParameters { Property = SortParameters.PropertyOption.ProjectName, Direction = SortParameters.DirectionOption.ASC }; var projectRequest = new ProjectsRequest(sortParameters); var sortedProjects = await groupShareClient.Project.GetProject(projectRequest); var projects = await groupShareClient.Project.GetAllProjects(); Assert.True(sortedProjects.Items.Count == projects.Items.Count); var projectsNames = projects.Items.Select(p => p.Name).ToList(); projectsNames.Sort(); int i = 0; foreach (var proj in sortedProjects.Items) { Assert.True(string.Compare(proj.Name, projectsNames[i++], StringComparison.CurrentCultureIgnoreCase) == 0); } }
public PagedDataViewer(ITradeService tradeService, ISchedulerProvider schedulerProvider) { //build observable predicate from search text var filter = this.WhenValueChanged(t => t.SearchText) .Throttle(TimeSpan.FromMilliseconds(250)) .Select(BuildFilter); //build observable sort comparer var sort = SortParameters.WhenValueChanged(t => t.SelectedItem) .Select(prop => prop.Comparer) .ObserveOn(schedulerProvider.Background); //build observable comparer var currentPageChanged = PageParameters.WhenValueChanged(p => p.CurrentPage); var pageSizeChanged = PageParameters.WhenValueChanged(p => p.PageSize); var pager = currentPageChanged.CombineLatest(pageSizeChanged, (page, size) => new PageRequest(page, size)) .StartWith(new PageRequest(1, 25)) .DistinctUntilChanged() .Sample(TimeSpan.FromMilliseconds(100)); // filter, sort, page and bind to observable collection _cleanUp = tradeService.All.Connect() .Filter(filter) // apply user filter .Transform(trade => new TradeProxy(trade), new ParallelisationOptions(ParallelType.Ordered, 5)) .Sort(sort, SortOptimisations.ComparesImmutableValuesOnly) .Page(pager) .ObserveOn(schedulerProvider.MainThread) .Do(changes => PageParameters.Update(changes.Response)) .Bind(out _data) // update observable collection bindings .DisposeMany() // dispose when no longer required .Subscribe(); }
public async Task <IHttpActionResult> GetVehicleModelsAsync(string search, int?makeId, string sortOrder = "", int?page = 1, int pageSize = 5, string sortBy = "") { var filter = new FilterParameters { Search = search, MakeId = makeId }; var sort = new SortParameters { SortBy = sortBy, SortOrder = sortOrder }; var pagep = new PageParameters { Page = (int)page, PageSize = pageSize, }; var vmlist = await _vehicleModelService.GetVehicleModelsAsync(sort, filter, pagep); return(Ok(new { Data = vmlist, PaggingInfo = vmlist.GetMetaData() })); }
/// <summary> /// Get method, /// /api/VehicleMake/?page=&pagesize=5&search=&sort=&direction= /// </summary> /// <param name="page">Current page</param> /// <param name="pagesize">Page size, if page size is not given it's set to 0</param> /// <param name="search">Search</param> /// <param name="sort">Sort by Name or Abrv</param> /// <param name="direction">Sort direction it can be ascending or descending</param> /// <returns>Returns a list of VehicleMakeVM</returns> public async Task <IHttpActionResult> Get(int?page, int?pagesize, string search, string sort, string direction) { var sortParameters = new SortParameters() { Sort = sort, SortDirection = direction ?? "Descending" }; var filterParameters = new FilterParameters() { Search = search }; var pageParameters = new PageParameters() { Page = page ?? 1, /*I set the page size to 0, because as you can see in VehicleMakeService when page size is set to 0 it skips pagging. * Because in one case I need to get all of thevehicle makes. * Example is in angular part when I need to get all VehicleMakes when I'm creating a new VehicleModel, * it needs VehicleMakeId to be created. * So a drop down menu with all Vehicle Makes can be created from which VehicleMakeId can be chosen from. */ PageSize = pagesize ?? 0 }; var vehicleMakeListPaged = AutoMapper.Mapper.Map <IPagedResult <VehicleMakeVM> >(await service.GetVehicleMakesAsync(sortParameters, filterParameters, pageParameters)); return(Ok(vehicleMakeListPaged)); }
public async Task <IHttpActionResult> GetVehicleMakesAsync(string search, int?page = 1, int pageSize = 5, string sortOrder = "", string sortBy = "") { var filter = new FilterParameters { Search = search }; var sort = new SortParameters { SortBy = sortBy, SortOrder = sortOrder }; var pagep = new PageParameters { Page = (int)page, PageSize = pageSize }; var vmlist = await _vehicleMakeService.GetVehicleMakesAsync(sort, filter, pagep); var makeVMList = AutoMapper.Mapper.Map <IEnumerable <VehicleMakeVM> >(vmlist); return(Ok(new { Data = makeVMList, PaggingInfo = vmlist.GetMetaData() })); }
public void SortText_ParameterPropertyIsNull_Expetion() { //Given var parameters = new SortParameters(); //When,Then Assert.ThrowsException <ArgumentNullException>(() => { SortService.SortText(parameters); }); }
public ActionResult videoList(int pageIndex = 1, int pageSize = 10) { List <video> list = new List <sjth.Model.video>(); List <video> li = new List <video>(); ViewData["pageIndex"] = pageIndex; ViewData["pageSize"] = pageSize; ViewData["total"] = 0; string name = Request["name"]; string start = Request["start"]; string end = Request["end"]; try { StringBuilder where = new StringBuilder(); where.Append(" and del =1 "); if (!string.IsNullOrWhiteSpace(name)) { where.Append(" and name like'%" + name.Trim() + "%'"); } if (!string.IsNullOrWhiteSpace(start) && !string.IsNullOrWhiteSpace(end)) { //where.Append(" and creationtime>='" + start + "'"); //creationtime between '2016-12-07' and '2016-12-08 23:59:59' where.Append(" and datatimes between '" + start + "' and '" + end + " 23:59:59'"); } if (!string.IsNullOrWhiteSpace(start) && string.IsNullOrWhiteSpace(end)) { where.Append(" and datatimes>='" + start + "'"); } if (string.IsNullOrWhiteSpace(start) && !string.IsNullOrWhiteSpace(end)) { where.Append(" and datatimes<='" + end + " 23:59:59'"); } SortParameter sa = new SortParameter(); sa.Field = "datatimes"; sa.Direction = SortDirection.DESC; SortParameters ot = new SortParameters(); ot.Add(sa); int totalcount = 0; list = _video.GetPage(out totalcount, pageIndex, pageSize, where.ToString(), "", ot); // list = newsbll.getall(); ViewData["total"] = totalcount; // list = _video.allList(); return(View(list)); } catch (Exception) { return(View(list)); } }
public SortTextModel SortText(SortParameters parameters) { if (parameters == null || parameters.Text == null) { throw new ArgumentNullException(); } var sortStrategy = GetSortStrategy(parameters.SortOptions); SortTextModel result = sortStrategy.Sort(parameters.Text, parameters.Asc); return(result); }
public void TestInvalidUpdateTemplatesInjection(SortParameters param, Enums.InvalidInjection invalid) { var handler = new DefaultManager(); var request = BuildSortRequest(1, new List <int> { Id }); request[param.GetEnumStringValue()] = MapperData.InvalidInjectionMapper[invalid]; var response = handler.Send <object>(TemplatesEndPoint, JsonConvert.SerializeObject(request), HttpMethod.PUT); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest)); }
private bool _isSorted(Figure[] array, SortParameters parameters) { if (array == null) { throw new ArgumentException("Передайте существующий массив для проверки."); } for (int i = 1; i < array.Length; i++) { if (parameters == SortParameters.Square ? (array[i - 1].GetSquare() > array[i].GetSquare()) : (array[i - 1].GetPerimeter() > array[i].GetPerimeter())) { return(false); } } return(true); }
public ActionResult school(int pageIndex = 1, int pageSize = 10, int?id = 0) { List <newstype> typelist = new List <newstype>(); string whereS = " PPID=2 and del =1"; typelist = newstypeBLL.GetAll(whereS); ViewBag.data = typelist; List <newst> list = new List <newst>(); List <newsName> li = new List <newsName>(); ViewData["pageIndex"] = pageIndex; ViewData["pageSize"] = pageSize; ViewData["total"] = 0; ViewData["name"] = newstypeBLL.GetById((int)id).typename; int totalcount = 0; StringBuilder where = new StringBuilder(); where.Append(" and del =1 and newstype = " + id); SortParameter sa = new SortParameter(); sa.Field = "creationtime"; sa.Direction = SortDirection.DESC; SortParameters ot = new SortParameters(); ot.Add(sa); list = newsbll.GetPage(out totalcount, pageIndex, pageSize, where.ToString(), "", ot); // list = newsbll.getall(); ViewData["total"] = totalcount; if (list.Count > 0) { foreach (var item in list) { newsName model = new newsName(); model.id = item.id; model.headline = item.headline; model.newstype = item.newstype; model.newstypename = newstypeBLL.GetById((int)item.newstype).typename; model.userid = item.userid; model.del = item.del; model.creationtime = item.creationtime; model.contenttext = item.contenttext; li.Add(model); } } return(View(li)); }
/// <summary> /// Sorts a portion of a list. The range to sort is [<paramref name="begin"/>, <paramref name="end"/>). /// </summary> /// <typeparam name="T">The type of items in the list.</typeparam> /// <param name="parameters">The source list, comparison object, and other lists that must be kept in sync.</param> /// <param name="begin">The beginning of the range to sort.</param> /// <param name="end">The ending of the range to sort.</param> private static void QuickSortCore <T>(SortParameters <T> parameters, int begin, int end) { // Empty lists and single-element lists are sorted by definition if (begin >= end - 1) { return; } // Choose a pivot element (we just choose the first one), and partition around it int newPivotIndex = QuickSortPartition(parameters, begin, end, begin); // Sort the left side (not including the pivot element) QuickSortCore(parameters, begin, newPivotIndex); // Sort the right side (not including the pivot element) QuickSortCore(parameters, newPivotIndex + 1, end); }
public async Task SortProjectsByName() { var groupShareClient = await Helper.GetGroupShareClient(); var sortParameters = new SortParameters() { Property = SortParameters.PropertyOption.ProjectName, Direction = SortParameters.DirectionOption.DESC }; var projectRequest = new ProjectsRequest(sortParameters); var sortedProjects = await groupShareClient.Project.GetProject(projectRequest); var projects = await groupShareClient.Project.GetAllProjects(); Assert.True(sortedProjects.Items.Count == projects.Items.Count); }
public ActionResult Sort(TextInputModel text, SortOptionInputModel sortOption) { if (!ModelState.IsValid) { return(GetErrorResponse()); } SortParameters parameters = new SortParameters() { Text = GetText(text.File), SortOptions = sortOption.SortOptions, Asc = sortOption.Asc }; var order = sortService.SortText(parameters); return(Json(order)); }
public void TestInvalidSortTemplate(SortParameters param, InvalidValue invalid) { var handler = new DefaultManager(); var request = BuildSortRequest(1, Ids); var item = request["template_0"] as Dictionary <string, object>; if (invalid == InvalidValue.MissingParam) { item.Remove(param.GetEnumStringValue()); } else { InvalidValueMapper[invalid](item, param.GetEnumStringValue()); } request["template_0"] = item; var response = handler.Send <object>(TemplatesEndPoint, JsonConvert.SerializeObject(request), HttpMethod.PUT); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest)); }
public async Task <IEnumerable <PaymentRequest> > SelectPaymentRequestsAsync ( SearchParameters searchParameters, SortParameters sortParameters ) { using (var context = ContextFactory.CreateDbContext(ConnectionString)) { var query = context.PaymentRequests.AsQueryable(); if (searchParameters?.Column != null && searchParameters.Prefix != null) { query = query.Where(request => typeof(PaymentRequest) .GetProperty(searchParameters.Column) .GetValue(request) .ToString() .StartsWith(searchParameters.Prefix)); } if (sortParameters?.Column != null) { if (sortParameters.DescendingOrder) { query = query.OrderByDescending(payment => typeof(PaymentRequest) .GetProperty(sortParameters.Column) .GetValue(payment) .ToString()); } else { var columnProp = typeof(PaymentRequest).GetProperty(sortParameters.Column); query = query.OrderBy(payment => columnProp .GetValue(payment) .ToString()); } } return(await query.ToListAsync().ConfigureAwait(false)); } }
public PagedDataViewer(ILogger logger, ITradeService tradeService, ISchedulerProvider schedulerProvider) { _logger = logger; //watch for filter changes and change filter var filterController = new FilterController <Trade>(trade => true); var filterApplier = this.ObservePropertyValue(t => t.SearchText) .Throttle(TimeSpan.FromMilliseconds(250)) .Select(propargs => BuildFilter(propargs.Value)) .Subscribe(filterController.Change); //watch for changes to sort and apply when necessary var sortContoller = new SortController <TradeProxy>(SortExpressionComparer <TradeProxy> .Ascending(proxy => proxy.Id)); var sortChange = SortParameters.ObservePropertyValue(t => t.SelectedItem).Select(prop => prop.Value.Comparer) .ObserveOn(schedulerProvider.TaskPool) .Subscribe(sortContoller.Change); //watch for page changes and change filter var pageController = new PageController(); var currentPageChanged = PageParameters.ObservePropertyValue(p => p.CurrentPage).Select(prop => prop.Value); var pageSizeChanged = PageParameters.ObservePropertyValue(p => p.PageSize).Select(prop => prop.Value); var pageChanger = currentPageChanged.CombineLatest(pageSizeChanged, (page, size) => new PageRequest(page, size)) .DistinctUntilChanged() .Sample(TimeSpan.FromMilliseconds(100)) .Subscribe(pageController.Change); // filter, sort, page and bind to loaded data var loader = tradeService.All.Connect() .Filter(filterController) // apply user filter .Transform(trade => new TradeProxy(trade), new ParallelisationOptions(ParallelType.Ordered, 5)) .Sort(sortContoller, SortOptimisations.ComparesImmutableValuesOnly) .Page(pageController) .ObserveOn(schedulerProvider.MainThread) .Do(changes => _pageParameters.Update(changes.Response)) .Bind(_data) // update observable collection bindings .DisposeMany() //since TradeProxy is disposable dispose when no longer required .Subscribe(); _cleanUp = new CompositeDisposable(loader, filterController, filterApplier, sortChange, sortContoller, pageChanger, pageController); }
public ActionResult product(int pageIndex = 1, int pageSize = 10) { ViewData["pageIndex"] = pageIndex; ViewData["pageSize"] = pageSize; ViewData["total"] = 0; int totalcount = 0; List <product> list = new List <product>(); StringBuilder where = new StringBuilder(); SortParameter sa = new SortParameter(); sa.Field = "datatimes"; sa.Direction = SortDirection.DESC; SortParameters ot = new SortParameters(); ot.Add(sa); where.Append(" and del =1 "); list = _productbll.GetPage(out totalcount, pageIndex, pageSize, where.ToString(), "", ot); ViewData["total"] = totalcount; return(View(list)); }
public async Task <IHttpActionResult> Get(int?page, int?pagesize, string search, string sort, string direction, int?makeid) { var sortParameters = new SortParameters() { Sort = sort, SortDirection = direction ?? "Descending" }; var filterParameters = new FilterParameters() { Search = search, VehicleMakeId = makeid }; var pageParameters = new PageParameters() { Page = page ?? 1, PageSize = pagesize ?? 5 }; var vehicleModelListPaged = AutoMapper.Mapper.Map <IPagedResult <VehicleModelVM> >(await service.GetVehicleModelsAsync(sortParameters, filterParameters, pageParameters)); return(Ok(vehicleModelListPaged)); }
public ActionResult VehicleMakeList(int?page, string sort, string direction, string search) { var sortParameters = new SortParameters() { Sort = sort, Direction = direction }; var filterParameters = new FilterParameters() { Search = search }; var pagingParameters = new PageParameters() { Page = page ?? 1, PageSize = 3 }; var vehicleMakeList = vehicleMakeService.GetVehicleMakePaged(sortParameters, filterParameters, pagingParameters); ViewBag.search = search; ViewBag.sort = sort; ViewBag.direction = direction; var makeListViewModel = AutoMapper.Mapper.Map <IEnumerable <MakeViewModel> >(vehicleMakeList); return(View(new StaticPagedList <MakeViewModel>(makeListViewModel, vehicleMakeList.GetMetaData()))); }
public ActionResult newsList(int pageIndex = 1, int pageSize = 10) { List <newst> list = new List <newst>(); List <newsName> li = new List <newsName>(); ViewData["pageIndex"] = pageIndex; ViewData["pageSize"] = pageSize; ViewData["total"] = 0; try { string name = Request["name"]; string start = Request["start"]; string end = Request["end"]; int totalcount = 0; StringBuilder where = new StringBuilder(); where.Append(" and del =1 "); if (!string.IsNullOrWhiteSpace(name)) { where.Append(" and headline like'%" + name.Trim() + "%'"); } if (!string.IsNullOrWhiteSpace(start) && !string.IsNullOrWhiteSpace(end)) { //where.Append(" and creationtime>='" + start + "'"); //creationtime between '2016-12-07' and '2016-12-08 23:59:59' where.Append(" and creationtime between '" + start + "' and '" + end + " 23:59:59'"); } if (!string.IsNullOrWhiteSpace(start) && string.IsNullOrWhiteSpace(end)) { where.Append(" and creationtime>='" + start + "'"); } if (string.IsNullOrWhiteSpace(start) && !string.IsNullOrWhiteSpace(end)) { where.Append(" and creationtime<='" + end + " 23:59:59'"); } SortParameter sa = new SortParameter(); sa.Field = "creationtime"; sa.Direction = SortDirection.DESC; SortParameters ot = new SortParameters(); ot.Add(sa); list = newsbll.GetPage(out totalcount, pageIndex, pageSize, where.ToString(), "", ot); // list = newsbll.getall(); ViewData["total"] = totalcount; if (list.Count > 0) { foreach (var item in list) { newsName model = new newsName(); model.id = item.id; model.headline = item.headline; model.newstype = item.newstype; model.newstypename = newstypeBLL.GetById((int)item.newstype).typename; model.userid = item.userid; model.del = item.del; model.creationtime = item.creationtime; model.contenttext = item.contenttext; li.Add(model); } } } catch (Exception) { } return(View(li)); }
/// <summary> /// 获取简单分页数据,默认按照Id升序排序 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="totalCount">总记录数</param> /// <param name="pageNumber">页索引</param> /// <param name="pageSize">页大小</param> /// <param name="condition">查询条件</param> /// <param name="param">查询参数</param> /// <param name="sort"></param> /// <returns></returns> public List <T> GetPage(out int count, int pageNumber = 1, int pageSize = 20, string condition = null, object param = null, SortParameters sort = null) { T t = new T(); string key = string.Format(NEWS_PAGE, pageNumber, pageSize, condition, t.GetType().Name); int totalCount; var list = _iBaseManager.GetPage(out totalCount, pageNumber, pageSize, condition, param, sort); count = totalCount; return(new PageModel <T>(pageSize, pageNumber, totalCount, list)); }
/// <summary> /// 获取简单分页数据,默认按照Id升序排序 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="totalCount">总记录数</param> /// <param name="pageNumber">页索引</param> /// <param name="pageSize">页大小</param> /// <param name="condition">查询条件</param> /// <param name="param">查询参数</param> /// <param name="sort"></param> /// <returns></returns> public List <T> GetPage(out int totalCount, int pageNumber = 1, int pageSize = 20, string condition = null, object param = null, SortParameters sort = null) { string sql4list = string.Empty; try { string subsql4sort = "ORDER BY [id]"; if (sort != null && sort.Count > 0) { List <string> list = new List <string>(); foreach (var item in sort) { list.Add(string.Format(" [{0}] {1}", item.Field, item.Direction == SortDirection.ASC ? "ASC" : "DESC")); } subsql4sort = string.Format("ORDER BY {0}", string.Join(",", list)); } sql4list = @" SELECT id,{0} FROM ( SELECT ROW_NUMBER() OVER({5}) AS ROW_NUM,{0},id FROM [{1}] WHERE 1 = 1 {4} )AS TEMP WHERE TEMP.ROW_NUM BETWEEN {2} AND {3}"; string sql4count = string.Format("SELECT COUNT(1) FROM {0} WHERE 1 = 1 {1}", TableName <T>(), condition); int beginIndex = (pageNumber - 1) * pageSize + 1; int endIndex = pageNumber * pageSize; sql4list = string.Format(sql4list, FieldNames(typeof(T)), TableName <T>(), beginIndex, endIndex, condition, subsql4sort); totalCount = Run(conn => Convert.ToInt32(conn.ExecuteScalar(sql4count, param))); return(Run(conn => conn.Query <T>(sql4list, param).ToList())); } catch (Exception e) { Logger.writeInfos("-----------public List<T> GetPage(out int totalCount, int pageNumber = 1, int pageSize = 20, string condition = null, object param = null, SortParameters sort = null)-----------\r\n" + sql4list + "\r\n" + e.Message + "\r\n"); totalCount = 0; return(null); } }
static void startSort(Object obj) { SortParameters sortParams = (SortParameters)obj; sortParams.instance.QuickSorting(sortParams.ints, sortParams.left, sortParams.right); }