private static bool ApplySkipOrTakeInDbIfPossible(QueryDescription query, ref IQueryOver <AggregateNodeStatus, AggregateNodeStatus> filteredAggQuery) { bool modified = false; if (CanApplySortOrderInDb(query) != ApplySortOrderInDb.CannotApplyAll) { foreach (var filter in query.ResultFilters) { switch (filter.ResultFilterType) { case ResultFilterType.Skip: filteredAggQuery = (IQueryOver <AggregateNodeStatus, AggregateNodeStatus>) filteredAggQuery.Skip(filter.SkipCount).Take(9999); modified = true; break; case ResultFilterType.Take: filteredAggQuery = (IQueryOver <AggregateNodeStatus, AggregateNodeStatus>) filteredAggQuery.Take(filter.TakeCount); modified = true; break; } } } return(modified); }
public List <Stok> SearchStokByCriter(Stok stok) { IQueryOver <Stok, Stok> over = Session.QueryOver <Stok>().Where(x => (x.Sube.Id == stok.Sube.Id || x.SubelerdeOrtak == true)); if (!string.IsNullOrEmpty(stok.Id)) { over.Where(s => s.Id.IsLike(stok.Id, MatchMode.Start)); } if (!string.IsNullOrEmpty(stok.StokAdi)) { over.Where(s => s.StokAdi.IsLike(stok.StokAdi, MatchMode.Start)); } if (!string.IsNullOrEmpty(stok.Grup1.Id)) { over.Where(s => s.Grup1.Id.IsLike(stok.Grup1.Id, MatchMode.Start)); } if (!string.IsNullOrEmpty(stok.Grup2.Id)) { over.Where(s => s.Grup2.Id.IsLike(stok.Grup2.Id, MatchMode.Start)); } if (!string.IsNullOrEmpty(stok.Grup3.Id)) { over.Where(s => s.Grup3.Id.IsLike(stok.Grup3.Id, MatchMode.Start)); } if (!string.IsNullOrEmpty(stok.Grup4.Id)) { over.Where(s => s.Grup4.Id.IsLike(stok.Grup4.Id, MatchMode.Start)); } if (!string.IsNullOrEmpty(stok.Grup5.Id)) { over.Where(s => s.Grup5.Id.IsLike(stok.Grup5.Id, MatchMode.Start)); } return(over.Take(GetMaxResult).List() as List <Stok>); }
public TempEnrollee GetTempEnrolleebystaffid(string staffid) { //var query = _session.QueryOver<TempEnrollee>().Where(x => x.staffid == staffid.ToUpper() || x.staffid == staffid.ToLower()); IQueryOver <TempEnrollee, TempEnrollee> query = _session.QueryOver <TempEnrollee>().Where(x => x.Staffprofileid == Convert.ToInt32(staffid)); return(query.Take(1).SingleOrDefault()); }
/// <summary> /// Versuch über ein Detached Criteria die Where-Klauseln zu verarbeiten, damit es mit dem Order nicht zu /// komplikationen kommt. /// </summary> protected virtual IPage <T> Find(IPageable pageable, Action <IQueryOver <T, T> > criteriaBuilder, Action <IQueryOver <T, T> > ordersBuilder = null) { Require.NotNull(pageable, "pageable"); Require.NotNull(criteriaBuilder, "criteriaBuilder"); HibernateDelegate <IPage <T> > finder = delegate(ISession session) { IQueryOver <T, T> query = session.QueryOver <T>(); criteriaBuilder(query); if (ordersBuilder != null) { ordersBuilder(query); } IQueryOver <T, T> countQuery = session.QueryOver <T>(); criteriaBuilder(countQuery); query.Skip(pageable.FirstItem); query.Take(pageable.PageSize); long futureTotalCount = countQuery.RowCountInt64(); IEnumerable <T> futureElements = query.Future <T>(); Page <T> page = new Page <T>(futureElements.ToList(), pageable, futureTotalCount); return(page); }; return(HibernateTemplate.Execute(finder)); }
public static IList <T> GetQueryOver <T>(IQueryOver <T, T> query, List <SortOrder <T> > expressionOrder, Pagination pagination) { if (expressionOrder != null) { for (int i = 0; i < expressionOrder.Count; i++) { var model = expressionOrder[i]; IQueryOverOrderBuilder <T, T> sort; if (i > 0) { sort = query.ThenBy(model.value); } else { sort = query.OrderBy(model.value); } if (model.searchType == EnumBase.OrderType.Asc) { query = sort.Asc; } else { query = sort.Desc; } } } if (pagination != null) { query.Skip((pagination.pageIndex - 1) * pagination.pageSize); query.Take(pagination.pageSize); } var list = query.List <T>(); return(list); }
public List <Cari> SearchCariByCriter(Cari cari) { IQueryOver <Cari, Cari> over = Session.QueryOver <Cari>().Where(x => (x.Sube.Id == cari.Sube.Id || x.SubelerdeOrtak == true)); if (!string.IsNullOrEmpty(cari.Id)) { over.Where(x => x.Id.IsLike(cari.Id, MatchMode.Start)); } if (!string.IsNullOrEmpty(cari.CariIsim)) { over.Where(x => x.CariIsim.IsLike(cari.CariIsim, MatchMode.Start)); } if (!string.IsNullOrEmpty(cari.CariTip)) { over.Where(x => x.CariTip.IsLike(cari.CariTip, MatchMode.Start)); } if (!string.IsNullOrEmpty(cari.Grup1.Id)) { over.Where(x => x.Grup1.Id.IsLike(cari.Grup1.Id, MatchMode.Start)); } if (!string.IsNullOrEmpty(cari.Grup2.Id)) { over.Where(x => x.Grup2.Id.IsLike(cari.Grup2.Id, MatchMode.Start)); } if (!string.IsNullOrEmpty(cari.Grup3.Id)) { over.Where(x => x.Grup3.Id.IsLike(cari.Grup3.Id, MatchMode.Start)); } if (!string.IsNullOrEmpty(cari.Grup4.Id)) { over.Where(x => x.Grup4.Id.IsLike(cari.Grup4.Id, MatchMode.Start)); } return(over.Take(GetMaxResult).List() as List <Cari>); }
public AdminTree GetTree(int?id) { AdminTree adminTree = new AdminTree { RootContoller = "Webpage" }; IQueryOver <Webpage, Webpage> query = _session.QueryOver <Webpage>().Where(x => x.Parent.Id == id); int maxChildNodes = 1000; if (id.HasValue) { Webpage parent = _session.Get <Webpage>(id); if (parent != null) { DocumentMetadata metaData = parent.GetMetadata(); maxChildNodes = metaData.MaxChildNodes; query = ApplySort(metaData, query); } } else { adminTree.IsRootRequest = true; query = query.OrderBy(x => x.DisplayOrder).Asc; } int rowCount = query.Cacheable().RowCount(); query.Take(maxChildNodes).Cacheable().List().ForEach(doc => { DocumentMetadata documentMetadata = doc.GetMetadata(); AdminTreeNode node = new AdminTreeNode { Id = doc.Id, ParentId = doc.ParentId, Name = doc.Name, IconClass = documentMetadata.IconClass, NodeType = "Webpage", Type = documentMetadata.Type.FullName, HasChildren = _treeNavService.GetWebpageNodes(doc.Id).Nodes.Any(), Sortable = documentMetadata.Sortable, CanAddChild = _validWebpageChildrenService.AnyValidWebpageDocumentTypes(doc), IsPublished = doc.Published, RevealInNavigation = doc.RevealInNavigation, Url = _urlHelper.Action("Edit", "Webpage", new { id = doc.Id }) }; adminTree.Nodes.Add(node); }); if (rowCount > maxChildNodes) { adminTree.Nodes.Add(new AdminTreeNode { IconClass = "glyphicon glyphicon-plus", IsMoreLink = true, ParentId = id, Name = (rowCount - maxChildNodes) + " More", Url = _urlHelper.Action("Search", "WebpageSearch", new { parentId = id }), }); } return(adminTree); }
/// <summary> /// Paging extensions of <see cref="IQueryOver{TRoot}"/> /// </summary> /// <typeparam name="T">{T}</typeparam> /// <param name="queryOver"><see cref="IQueryOver{TRoot}"/></param> /// <param name="currentPage">Current page</param> /// <param name="pageSize">Page size</param> /// <param name="records">Records</param> /// <returns><see cref="IPaging{T}"/></returns> public static IPaging <T> Paging <T>(this IQueryOver <T> queryOver, int currentPage, int pageSize, long?records) { queryOver.Skip(currentPage * pageSize); queryOver.Take(pageSize); return(records.HasValue ? queryOver.List <T>().Paging(currentPage, pageSize, records.Value) : queryOver.List <T>().Paging(currentPage, pageSize)); }
/// <summary> /// Esegue la paginazione dei dati. /// </summary> /// <param name="queryOver"></param> /// <returns></returns> protected virtual IQueryOver <T, T> ExecutePaging(IQueryOver <T, T> queryOver) { if (EnablePaging) { queryOver.Skip(PageIndex); queryOver.Take(PageSize); } return(queryOver); }
public static IQueryOver <TRoot> AddTake <TRoot>(this IQueryOver <TRoot> queryOver, int?take) { if (take.HasValue && take.Value > 0) { return(queryOver.Take(take.Value)); } return(queryOver); }
static public IQueryOver <Model> ApplyPaging <Model>(this IQueryOver <Model, Model> query, PartialRetrievingInfo retrievingInfo) { if (retrievingInfo.PageSize > PartialRetrievingInfo.AllElementsPageSize) { return(query.Take(retrievingInfo.PageSize).Skip(retrievingInfo.PageIndex * retrievingInfo.PageSize)); } else { return(query); } }
/// <summary> /// 分页查询 /// </summary> /// <param name="predicate">条件</param> /// <param name="pageSize">页大小</param> /// <param name="pageNum">页码,从 1 开始</param> /// <param name="orderbyStrings"></param> /// <returns>返回结果集</returns> public IList <TEntity> QueryPage(Expression <Func <TEntity, bool> > predicate, int pageSize, int pageNum, params string[] orderbyStrings) { IQueryOver <TEntity, TEntity> query = session.QueryOver <TEntity>().Where(predicate); query = orderbyStrings.Select(RepositoryHelper.ParseOrderbyString). Aggregate(query, (current, tup) => tup.Item2 ? current.OrderBy(Projections.Property(tup.Item1)).Desc : current.OrderBy(Projections.Property(tup.Item1)).Asc); return(query.Take(pageSize * pageNum).Skip(pageSize * (pageNum - 1)).List()); }
public static IQueryOver <T> Paged <T>(this IQueryOver <T, T> query, int first, int length) { if (first > 0) { query.Skip(first); } if (length > 0) { query.Take(length); } return(query); }
public IPage <TResult> FindPage <TResult>(IQueryOver <TResult, TResult> queryOver, IPageable pageRequest) { IQueryOver <TResult, TResult> countQuery = queryOver.Clone().ClearOrders().ToRowCountInt64Query(); countQuery.Skip(0).Take(int.MaxValue); IFutureValue <long> rowCount = countQuery.Select(Projections.RowCountInt64()).FutureValue <long>(); queryOver.Skip(pageRequest.FirstItem); queryOver.Take(pageRequest.PageSize); IEnumerable <TResult> enumerable = queryOver.Future <TResult>(); return(new Page <TResult>(enumerable.ToList(), pageRequest, rowCount.Value)); }
public static IQueryOver <TEntity, TEntity> SkipTake <TEntity>( this IQueryOver <TEntity, TEntity> query, int skip, int take) { if (skip > 0) { query.Skip(skip); } if (skip > 0) { query.Take(take); } return(query); }
public static IQueryOver <People, People> Pagination(this IQueryOver <People, People> model, string skip, string top) { var skipAsInteger = string.IsNullOrEmpty(skip) ? 0 : int.Parse(skip); var topAsInteger = string.IsNullOrEmpty(top) ? 0 : int.Parse(top); if (skipAsInteger > 0) { model.Skip(skipAsInteger); } if (topAsInteger > 0) { model.Take(topAsInteger); } return(model); }
public AdminTree GetTree(int?id) { Webpage parent = id.HasValue ? _session.Get <Webpage>(id) : null; var adminTree = new AdminTree { RootContoller = "Webpage", IsRootRequest = parent == null }; int maxChildNodes = parent == null ? 1000 : parent.GetMetadata().MaxChildNodes; IQueryOver <Webpage, Webpage> query = GetQuery(parent); int rowCount = GetRowCount(query); query.Take(maxChildNodes).Cacheable().List().ForEach(doc => { DocumentMetadata documentMetadata = doc.GetMetadata(); var node = new AdminTreeNode { Id = doc.Id, ParentId = doc.ParentId, Name = doc.Name, IconClass = documentMetadata.IconClass, NodeType = "Webpage", Type = documentMetadata.Type.FullName, HasChildren = _treeNavService.WebpageHasChildren(doc.Id), Sortable = documentMetadata.Sortable, CanAddChild = _validWebpageChildrenService.AnyValidWebpageDocumentTypes(doc), IsPublished = doc.Published, RevealInNavigation = doc.RevealInNavigation, Url = _urlHelper.Action("Edit", "Webpage", new { id = doc.Id }) }; adminTree.Nodes.Add(node); }); if (rowCount > maxChildNodes) { adminTree.Nodes.Add(new AdminTreeNode { IconClass = "glyphicon glyphicon-plus", IsMoreLink = true, ParentId = id, Name = (rowCount - maxChildNodes) + " More", Url = _urlHelper.Action("Search", "WebpageSearch", new { parentId = id }), }); } return(adminTree); }
/// <summary> /// Adds <see cref="paging"/> restrictions to <see cref="query"/>. /// </summary> protected void AddPaging <T>(IQueryOver <T, T> query, FilterBase paging, bool distinct = false) where T : EntityBase { if (query == null) { throw new ArgumentNullException("query"); } if (paging == null) { return; } if (paging.Take.HasValue) { query.Take(paging.Take.Value); } if (paging.Skip.HasValue) { query.Skip(paging.Skip.Value); } var rowQuery = distinct ? ToDistinctRowCount(query) : query.ToRowCountQuery(); paging.TotalCount = rowQuery.FutureValue <int>().Value; }
public IQueryOver <TRoot> Take(int maxResults) { SkipTakeUsed = true; MainQuery.Take(maxResults); return(this); }
public IList <PaymentBatch> getrecentpaymentbatch() { IQueryOver <PaymentBatch, PaymentBatch> query = _session.QueryOver <PaymentBatch>().Where(x => x.IsDeleted == false && x.status == PaymentStatus.Default || x.status == PaymentStatus.Pending).OrderBy(x => x.CreatedOn).Desc(); return(query.Take(1000).List()); }
/// <summary> /// chọn số lương row /// </summary> /// <param name="count"></param> /// <returns></returns> public IReponsitoryQuery <T> Take(int count) { _query.Take(count).Cacheable(); return(this); }
public TempEnrollee GetTempEnrolleebystaffProfileid(int staffid) { IQueryOver <TempEnrollee, TempEnrollee> query = _session.QueryOver <TempEnrollee>().Where(x => x.Staffprofileid == staffid); return(query.Take(1).SingleOrDefault()); }
public IQueryBuilder <T> Take(int value) { _query.Take(value); return(this); }