/// <summary> /// Make FreeSql.Select`1 source to FreeSqlPage collection. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="select"></param> /// <param name="pageSize"></param> /// <param name="limitedMemberCount"></param> /// <param name="includeNestedMembers"></param> /// <returns></returns> public static PaginableFreeSqlQuery <T> CreatePageSet <T>(ISelect <T> select, int?pageSize = null, int?limitedMemberCount = null, bool?includeNestedMembers = null) where T : class { if (select == null) { throw new ArgumentNullException(nameof(select)); } if (pageSize == null) { pageSize = PaginableSettingsManager.Settings.DefaultPageSize; } if (includeNestedMembers == null) { includeNestedMembers = false; } var size = pageSize.Value; var realMemberCount = GetRealMemberCountFunc()(limitedMemberCount)(FreeSqlHelper.Count(select).AsInt32()); var realPageCount = GetRealPageCountFunc()(realMemberCount)(size); return(limitedMemberCount.IsValid() && limitedMemberCount.HasValue ? new PaginableFreeSqlQuery <T>(select, size, realPageCount, realMemberCount, limitedMemberCount.Value, includeNestedMembers.Value) : new PaginableFreeSqlQuery <T>(select, size, realPageCount, realMemberCount, includeNestedMembers.Value)); }
/// <summary> /// Make queryable source to QueryablePage collection /// </summary> /// <typeparam name="T">element type of your queryable source</typeparam> /// <param name="queryable">original queryable result</param> /// <param name="pageSize">page size</param> /// <param name="limitedMemberCount">limited member count</param> /// <returns></returns> public static PageableQueryable <T> CreatePageSet <T>(IQueryable <T> queryable, int?pageSize = null, int?limitedMemberCount = null) { if (queryable is null) { throw new ArgumentNullException(nameof(queryable)); } pageSize ??= PageableSettingsManager.Settings.DefaultPageSize; var size = pageSize.Value; var realMemberCount = GetRealMemberCountFunc()(limitedMemberCount)(queryable.Count()); var realPageCount = GetRealPageCountFunc()(realMemberCount)(size); return(limitedMemberCount.IsValid() && limitedMemberCount.HasValue ? new PageableQueryable <T>(queryable, size, realPageCount, realMemberCount, limitedMemberCount.Value) : new PageableQueryable <T>(queryable, size, realPageCount, realMemberCount)); }
/// <summary> /// Make enumerable result to EnumerablePage collection /// </summary> /// <typeparam name="T">element type of your enumerable result</typeparam> /// <param name="enumerable">orgin enumerable result</param> /// <param name="pageSize">page size</param> /// <param name="limitedMemberCount">limited member count</param> /// <returns></returns> public static PaginableEnumerable <T> CreatePageSet <T>(IEnumerable <T> enumerable, int?pageSize = null, int?limitedMemberCount = null) { if (enumerable == null) { throw new ArgumentNullException(nameof(enumerable)); } if (pageSize == null) { pageSize = PaginableSettingsManager.Settings.DefaultPageSize; } var size = pageSize.Value; var realMemberCount = GetRealMemberCountFunc()(limitedMemberCount)(enumerable.Count()); var realPageCount = GetRealPageCountFunc()(realMemberCount)(size); return(limitedMemberCount.IsValid() && limitedMemberCount.HasValue ? new PaginableEnumerable <T>(enumerable, size, realPageCount, realMemberCount, limitedMemberCount.Value) : new PaginableEnumerable <T>(enumerable, size, realPageCount, realMemberCount)); }
/// <summary> /// Make NHibernate QueryOver`1 source to NHibernatePage collection. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="queryOver"></param> /// <param name="pageSize"></param> /// <param name="limitedMemberCount"></param> /// <returns></returns> public static PaginableNhCoreQuery <T> CreatePageSet <T>(IQueryOver <T> queryOver, int?pageSize = null, int?limitedMemberCount = null) { if (queryOver == null) { throw new ArgumentNullException(nameof(queryOver)); } if (pageSize == null) { pageSize = PaginableSettingsManager.Settings.DefaultPageSize; } var size = pageSize.Value; var realMemberCount = GetRealMemberCountFunc()(limitedMemberCount)(NhQueryOverHelper.Count(queryOver)); var realPageCount = GetRealPageCountFunc()(realMemberCount)(size); return(limitedMemberCount.IsValid() && limitedMemberCount.HasValue ? new PaginableNhCoreQuery <T>(queryOver, size, realPageCount, realMemberCount, limitedMemberCount.Value) : new PaginableNhCoreQuery <T>(queryOver, size, realPageCount, realMemberCount)); }
/// <summary> /// Make Dos.ORM Query`1 source to DosePage collection. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="query"></param> /// <param name="pageSize"></param> /// <param name="limitedMemberCount"></param> /// <param name="additionalQueryFunc"></param> /// <returns></returns> public static PaginableDosQuery <T> CreatePageSet <T>(FromSection <T> query, int?pageSize = null, int?limitedMemberCount = null, Func <FromSection <T>, FromSection <T> > additionalQueryFunc = null) where T : Entity { if (query == null) { throw new ArgumentNullException(nameof(query)); } if (pageSize == null) { pageSize = PaginableSettingsManager.Settings.DefaultPageSize; } var size = pageSize.Value; var realMemberCount = GetRealMemberCountFunc()(limitedMemberCount)(DosHelper.Count(query)); var realPageCount = GetRealPageCountFunc()(realMemberCount)(size); return(limitedMemberCount.IsValid() && limitedMemberCount.HasValue ? new PaginableDosQuery <T>(query, size, realPageCount, realMemberCount, limitedMemberCount.Value, additionalQueryFunc) : new PaginableDosQuery <T>(query, size, realPageCount, realMemberCount, additionalQueryFunc)); }