public static IQueryOver <T, T> ApplySorting <T>(this IQueryOver <T, T> query, SearchSortOrder sortOrder, bool sortAscending) where T : ISortable { IQueryOverOrderBuilder <T, T> orderBuilder = null; if (sortOrder == SearchSortOrder.Newest) { orderBuilder = query.OrderBy(x => x.CreationDate); } else if (sortOrder == SearchSortOrder.HighestRating) { orderBuilder = query.OrderBy(x => x.Rating); } else { orderBuilder = query.OrderBy(x => x.Name); } if (sortAscending) { query = orderBuilder.Asc; } else { query = orderBuilder.Desc; } return(query); }
/// <summary> /// The add order. /// </summary> /// <param name="criteria"> /// The criteria. /// </param> /// <param name="ac"> /// The ac. /// </param> /// <param name="gender"> /// The gender. /// </param> /// <param name="type"> /// The type. /// </param> /// <param name="query"> /// The query. /// </param> /// <returns> /// The <see cref="IQueryOver"/> . /// </returns> private IQueryOver <AutoComplete, AutoComplete> AddOrder( SearchAutoCompleteCriteria criteria, AutoComplete ac, Concept gender, Concept type, IQueryOver <AutoComplete, AutoComplete> query) { // Сортировка if (!string.IsNullOrEmpty(criteria.SortExpression)) { Expression <Func <object> > expression = () => ac.Name; switch (criteria.SortExpression) { case "Name": expression = () => ac.Name; break; case "Gender": expression = () => gender.Name; break; case "Type": expression = () => type.Name; break; } query = criteria.SortDirection == SortDirection.Ascending ? query.OrderBy(expression).Asc : query.OrderBy(expression).Desc; } return(query); }
/// <summary> /// Aggiungi l'espressione dalla griglia al finder /// </summary> /// <param name="conditions"></param> /// <param name="direction"></param> /// <returns></returns> protected virtual bool AttachSortExpressions(ref IQueryOver <T, T> queryOver, ICollection <SortExpression <T> > conditions) { if (conditions == null) { return(false); } try { // Attacca una collezione di espressioni SORT alla queryOver foreach (SortExpression <T> c in conditions) { // Ascendente if (c.Direction == SortDirection.Ascending) { queryOver.OrderBy(c.Expression).Asc(); } // Discendente else { queryOver.OrderBy(c.Expression).Desc(); } } } catch (Exception ex) { throw new DocSuiteException("Errore ordinamento", "Espressione di ordinamento non corretta", ex); } return(true); }
/// <summary> /// The add order. /// </summary> /// <param name="criteria"> /// The criteria. /// </param> /// <param name="pdp"> /// The organisation. /// </param> /// <param name="smo"> /// The smo. /// </param> /// <param name="query"> /// The query. /// </param> /// <returns> /// The <see cref="IQueryOver"/> . /// </returns> private IQueryOver <Organisation, Organisation> AddOrder( SearchPdpCriteria criteria, Organisation pdp, Organisation smo, IQueryOver <Organisation, Organisation> query) { // Сортировка if (!string.IsNullOrEmpty(criteria.SortExpression)) { Expression <Func <object> > expression = () => smo.ShortName; switch (criteria.SortExpression) { case "Smo": expression = () => smo.ShortName; break; case "ShortName": expression = () => pdp.ShortName; break; case "FullName": expression = () => pdp.FullName; break; } query = criteria.SortDirection == SortDirection.Ascending ? query.OrderBy(expression).Asc : query.OrderBy(expression).Desc; } return(query); }
private IQueryOver <MyTraining, MyTraining> getMyTrainingsCriterias(IQueryOver <MyTraining, MyTraining> queryProducts, GetMyTrainingsParam param) { queryProducts = queryProducts.ApplyUser(param, Session, SecurityInfo); if (queryProducts == null) { return(null); } if (param.MyTrainingId.HasValue) { queryProducts = queryProducts.Where(day => day.GlobalId == param.MyTrainingId.Value); } if (param.StartDate.HasValue) { queryProducts = queryProducts.Where(day => day.StartDate >= param.StartDate); } if (param.EndDate.HasValue) { queryProducts = queryProducts.Where(day => day.StartDate <= param.EndDate); } if (param.TrainingEnds.Count > 0) { var langOr = Restrictions.Disjunction(); foreach (var lang in param.TrainingEnds) { langOr.Add <MyTraining>(x => x.TrainingEnd == (TrainingEnd)lang); } queryProducts = queryProducts.And(langOr); } IQueryOverOrderBuilder <MyTraining, MyTraining> orderBuilder; switch (param.SortOrder) { case MyTrainingSortOrder.StartDate: orderBuilder = queryProducts.OrderBy(x => x.StartDate); break; case MyTrainingSortOrder.PercentageCompleted: orderBuilder = queryProducts.OrderBy(x => x.PercentageCompleted); break; default: orderBuilder = queryProducts.OrderBy(x => x.Name); break; } if (param.SortAscending) { queryProducts = orderBuilder.Asc; } else { queryProducts = orderBuilder.Desc; } return(queryProducts); }
private static IQueryOver <TScheme, TScheme> SetOrderByDirection(OrderByBuilder <TScheme> orderBy, IQueryOver <TScheme, TScheme> query) { // ReSharper disable once ConvertIfStatementToReturnStatement if (orderBy.OrderByDirection == OrderByDirection.Ascending) { return(query.OrderBy(orderBy.OrderExpresssion).Asc); } return(query.OrderBy(orderBy.OrderExpresssion).Desc); }
public static IQueryOver <T, T> AddOrders <T>(this IQueryOver <T, T> queryOver, params INHOrder[] orders) { foreach (var order in orders) { queryOver = order.Ascending ? queryOver.OrderBy(order.OrderExpr).Asc : queryOver.OrderBy(order.OrderExpr).Desc; } return(queryOver); }
public static IQueryOver <TRoot, TSubType> AddNameOrder <TRoot, TSubType>(IQueryOver <TRoot, TSubType> criteria, ContentLanguagePreference languagePreference) where TSubType : IEntryWithNames { switch (languagePreference) { case ContentLanguagePreference.Japanese: return(criteria.OrderBy(e => e.Names.SortNames.Japanese).Asc); case ContentLanguagePreference.English: return(criteria.OrderBy(e => e.Names.SortNames.English).Asc); default: return(criteria.OrderBy(e => e.Names.SortNames.Romaji).Asc); } }
/// <summary> /// Returns query with filters and sorting applied. /// </summary> /// <typeparam name="TRoot">The type of the entity.</typeparam> /// <typeparam name="TSubType">The type of the sub type.</typeparam> /// <param name="query">The query.</param> /// <param name="filter">The filter.</param> /// <param name="order">The order.</param> /// <param name="orderDescending">if set to <c>true</c> order descending.</param> /// <param name="pageNumber">The page number.</param> /// <param name="itemsPerPage">The items per page.</param> /// <returns>Query with filters and sorting applied</returns> public static IQueryOver <TRoot, TSubType> ApplyFilters <TRoot, TSubType>(this IQueryOver <TRoot, TSubType> query, Expression <Func <TSubType, bool> > filter = null, Expression <Func <TSubType, dynamic> > order = null, bool orderDescending = false, int?pageNumber = null, int?itemsPerPage = null) { if (filter != null) { query = query.Where(filter); } if (order != null) { query = (orderDescending) ? query.OrderBy(order).Desc : query.OrderBy(order).Asc; } query = query.AddPaging(pageNumber, itemsPerPage); return(query); }
public IList <ConnectCareSponsor> QueryConnectCareSponsor(out int totalRecord, out int totalcountinresult, string search, int start, int lenght, string fullname, string Policynumber, int senttomatontine, bool useDate, DateTime scrFromDate, DateTime scrToDate) { IQueryOver <ConnectCareSponsor, ConnectCareSponsor> query = _session.QueryOver <ConnectCareSponsor>().Where(x => x.IsDeleted == false); if (senttomatontine > -1) { bool sent = Convert.ToBoolean(senttomatontine); query.Where(x => x.pushedtoMatontine == sent); } if (!string.IsNullOrEmpty(fullname)) { fullname = "%" + fullname + "%"; query.Where(Restrictions.On <ConnectCareSponsor>(x => x.fullname).IsInsensitiveLike(fullname)); } if (!string.IsNullOrEmpty(Policynumber)) { query.Where(x => x.policynumber == Policynumber || x.policynumber == Policynumber.ToLower()); } if (useDate) { DateTime newenddate = Convert.ToDateTime(string.Format("{0}/{1}/{2} {3}", scrToDate.Month, scrToDate.Day, scrToDate.Year, "23:59")); query.Where(Restrictions.On <ConnectCareSponsor>(a => a.CreatedOn).IsBetween(scrFromDate).And(newenddate)); } //return normal list. totalRecord = query.RowCount(); totalcountinresult = totalRecord; return(query.OrderBy(x => x.CreatedOn).Desc.Skip(start).Take(lenght).List()); }
public IPagedList <Notification> Search(NotificationSearchQuery searchQuery) { IQueryOver <Notification, Notification> queryOver = _session.QueryOver <Notification>(); if (!string.IsNullOrWhiteSpace(searchQuery.Message)) { queryOver = queryOver.Where( notification => notification.Message.IsInsensitiveLike(searchQuery.Message, MatchMode.Anywhere)); } if (searchQuery.UserId.HasValue) { queryOver = queryOver.Where(notification => notification.User.Id == searchQuery.UserId); } if (searchQuery.From.HasValue) { queryOver = queryOver.Where(notification => notification.CreatedOn >= searchQuery.From); } if (searchQuery.To.HasValue) { queryOver = queryOver.Where(notification => notification.CreatedOn <= searchQuery.To); } if (searchQuery.NotificationType.HasValue) { queryOver = queryOver.Where(notification => notification.NotificationType == searchQuery.NotificationType); } return(queryOver.OrderBy(notification => notification.CreatedOn).Desc.Paged(searchQuery.Page)); }
/// <summary> /// Load list of T objects that match the specified criteria with support for paging and sorting /// </summary> /// <param name="paging"></param> /// <param name="sorting"></param> /// <param name="query">Query used to retrieve the T objects. If not specified, all objects will be returned</param> /// <returns></returns> public static List <T> Load(PagingOptions paging, SortingOptions <T> sorting, IQueryOver <T, T> useQuery = null) { IQueryOver <T, T> query = (useQuery == null) ? SessionManager.CurrentSession.QueryOver <T>() : useQuery; // Logging the method call _logger.Debug("{0}.Load(paging, sorting, useQuery)", typeof(T)); _logger.Debug("Paging: DontApplyPaging={0} Page={1} ResultsPerPage={2} ItemsCount={3} PageCount={4}", paging.DontApplyPaging, paging.Page, paging.ResultsPerPage, paging.ItemsCount, paging.PageCount); _logger.Debug("Sorting: DontApplySorting={0} OrderBy={1} SortOrder={2}", sorting.DontApplySorting, sorting.OrderBy.Body, sorting.SortOrder); // Aplly sorting if (!sorting.DontApplySorting) { var order = query.OrderBy(sorting.OrderBy); query = (sorting.SortOrder == SortOrder.Ascending) ? order.Asc : order.Desc; } // Apply paging if (!paging.DontApplyPaging) { // Update the paging object with the total number of records // so we can determine how many pages there are available UpdatePagingOptions((ICriteria)query.UnderlyingCriteria.Clone(), paging); // Limit the query results query.UnderlyingCriteria .SetFirstResult(paging.ResultsPerPage * paging.Page) .SetMaxResults(paging.ResultsPerPage); } return((List <T>)query.List <T>()); }
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 IPagedList <QueuedMessage> GetMessages(MessageQueueQuery searchQuery) { IQueryOver <QueuedMessage, QueuedMessage> queryOver = _session.QueryOver <QueuedMessage>().Where(message => message.Site == _site); if (searchQuery.From.HasValue) { queryOver = queryOver.Where(message => message.CreatedOn >= searchQuery.From); } if (searchQuery.To.HasValue) { queryOver = queryOver.Where(message => message.CreatedOn <= searchQuery.To); } if (!string.IsNullOrWhiteSpace(searchQuery.FromQuery)) { queryOver = queryOver.Where(message => message.FromAddress.IsInsensitiveLike(searchQuery.FromQuery, MatchMode.Anywhere) || message.FromName.IsInsensitiveLike(searchQuery.FromQuery, MatchMode.Anywhere)); } if (!string.IsNullOrWhiteSpace(searchQuery.ToQuery)) { queryOver = queryOver.Where(message => message.ToAddress.IsInsensitiveLike(searchQuery.ToQuery, MatchMode.Anywhere) || message.ToName.IsInsensitiveLike(searchQuery.ToQuery, MatchMode.Anywhere)); } if (!string.IsNullOrWhiteSpace(searchQuery.Subject)) { queryOver = queryOver.Where(message => message.Subject.IsInsensitiveLike(searchQuery.Subject, MatchMode.Anywhere)); } return(queryOver.OrderBy(message => message.CreatedOn).Desc.Paged(searchQuery.Page, _siteSettings.DefaultPageSize)); }
public IList <AuthorizationRequest> QueryallAuthRequest(out int totalRecord, out int totalcountinresult, string search, int start, int lenght, string sortColumn, string sortOrder, string Search, bool useDate, DateTime scrFromDate, DateTime scrToDate) { IQueryOver <AuthorizationRequest, AuthorizationRequest> query = _session.QueryOver <AuthorizationRequest>().Where(x => x.IsDeleted == false); if (!string.IsNullOrEmpty(Search)) { Search = "%" + Search + "%"; query.AndRestrictionOn(x => x.fullname).IsInsensitiveLike(search, MatchMode.Anywhere); } if (useDate) { DateTime datete = Convert.ToDateTime(scrToDate); int dd = datete.Day; int dmonth = datete.Month; int dyear = datete.Year; string time = "23:59"; DateTime enddate = Convert.ToDateTime(string.Format("{0}/{1}/{2} {3}", dmonth, dd, dyear, time)); query.Where(Restrictions.On <AuthorizationRequest>(a => a.CreatedOn).IsBetween(scrFromDate).And(enddate)); } totalRecord = query.RowCount(); totalcountinresult = totalRecord; IList <AuthorizationRequest> list = query.OrderBy(x => x.CreatedOn).Desc.Skip(start).Take(lenght).List(); return(list); }
public IPagedList <Article> GetArticles(ArticleList page, ArticleSearchModel model) { IQueryOver <Article, Article> query = _session.QueryOver <Article>() .Where(a => a.Parent == page); if (!string.IsNullOrEmpty(model.Category)) { Tag tagAlias = null; query = query.JoinAlias(article => article.Tags, () => tagAlias).Where(() => tagAlias.Name.IsInsensitiveLike(model.Category, MatchMode.Exact)); } if (model.Month.HasValue) { query = query.Where( article => article.PublishOn != null && article.PublishOn.Value.MonthPart() == model.Month); } if (model.Year.HasValue) { query = query.Where( article => article.PublishOn != null && article.PublishOn.Value.YearPart() == model.Year); } return(query.OrderBy(x => x.PublishOn).Desc.Paged(model.Page, page.PageSize)); }
public static Order LastOrder(this IQueryOver <Order, Order> query) { return(query .OrderBy(sr => sr.CompleteUtcTime).Desc .Take(1) .SingleOrDefault <Order>()); }
public IPage <Bill> FindDebitorBillsForUser(IPageable pageRequest, User user, bool?isSettled) { HibernateDelegate <IPage <Bill> > finder = delegate(ISession session) { Require.NotNull(pageRequest, "pageRequest"); Require.NotNull(user, "user"); /*Mitgliedschaften des Nutzers laden, da die Rechnungen gegen die Mitgliedschaft gehen*/ QueryOver <UserGroupMembership, UserGroupMembership> userGroupMembershipSubQuery = QueryOver.Of <UserGroupMembership>().Where(mem => mem.User == user).Select(mem => mem.Id); /*Subquery für die Rechnungen, bei denen der Nutzer Schuldner ist*/ IQueryOver <Bill, Bill> queryOver = session.QueryOver <Bill>(); queryOver.Right.JoinQueryOver <BillUserGroupDebitor>(bill => bill.UserGroupDebitors) .WithSubquery.WhereProperty(deb => deb.UserGroupMembership) .In(userGroupMembershipSubQuery); if (isSettled.HasValue) { queryOver.And(bill => bill.IsSettled == isSettled.Value); } queryOver = queryOver.OrderBy(bill => bill.CreatedAt).Desc; return(FindPage(queryOver, pageRequest)); }; return(HibernateTemplate.Execute(finder)); }
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); }
public IPagedList <ProductReview> Search(ProductReviewSearchQuery query) { IQueryOver <ProductReview, ProductReview> queryOver = _session.QueryOver <ProductReview>(); switch (query.ApprovalStatus) { case ApprovalStatus.Pending: queryOver = queryOver.Where(review => review.Approved == null); break; case ApprovalStatus.Rejected: queryOver = queryOver.Where(review => review.Approved == false); break; case ApprovalStatus.Approved: queryOver = queryOver.Where(review => review.Approved == true); break; } if (!string.IsNullOrWhiteSpace(query.ProductName)) { ProductVariant productVariantAlias = null; Product productAlias = null; queryOver = queryOver.JoinAlias(review => review.ProductVariant, () => productVariantAlias) .JoinAlias(() => productVariantAlias.Product, () => productAlias) .Where( () => productVariantAlias.Name.IsInsensitiveLike(query.ProductName, MatchMode.Anywhere) || productAlias.Name.IsInsensitiveLike(query.ProductName, MatchMode.Anywhere)); } if (!string.IsNullOrWhiteSpace(query.Email)) { User userAlias = null; queryOver = queryOver.JoinAlias(review => review.User, () => userAlias, JoinType.LeftOuterJoin) .Where( review => (review.Email.IsInsensitiveLike(query.Email, MatchMode.Anywhere)) || (userAlias.Email.IsInsensitiveLike(query.Email, MatchMode.Anywhere))); } if (!string.IsNullOrWhiteSpace(query.Title)) { queryOver = queryOver.Where(review => review.Title.IsLike(query.Title, MatchMode.Anywhere)); } if (query.DateFrom.HasValue) { queryOver = queryOver.Where(review => review.CreatedOn >= query.DateFrom); } if (query.DateTo.HasValue) { queryOver = queryOver.Where(review => review.CreatedOn < query.DateTo); } return (queryOver.OrderBy(review => review.Approved) .Asc.ThenBy(review => review.CreatedOn) .Desc.Paged(query.Page)); }
public virtual (IEnumerable <TEntity>, int) QueryByPage(IQueryOver <TEntity, TEntity> queryOver, Expression <Func <TEntity, object> > orderby, bool isDesc = false, int pageIndex = 1, int pageSize = 0) { var totalCount = queryOver.RowCount(); var orderQuery = queryOver.OrderBy(orderby); var orderByQuery = isDesc ? orderQuery.Desc : orderQuery.Asc; return(orderByQuery.Skip((pageIndex > 0 ? (pageIndex - 1) : 0) * (pageSize <= 0 ? totalCount : pageSize)).Take((pageSize <= 0 ? totalCount : pageSize)).List(), totalCount); }
public IEnumerable <TResult> All(SortType pSort, params Expression <Func <TResult, object> >[] pOrderBy) { for (short f = 0; f < pOrderBy.GetLength(0); f++) { if (pSort == SortType.Ascending) { _query = _query.OrderBy(pOrderBy[f]).Asc(); } else { _query = _query.OrderBy(pOrderBy[f]).Desc(); } } IEnumerable <TResult> _result = _query.List <TResult>(); return(_result); }
/// <summary> /// The filtering. /// </summary> /// <param name="query"> /// The query. /// </param> /// <param name="filter"> /// The filter. /// </param> /// <returns> /// The <see cref="IQueryOver"/>. /// </returns> public override IQueryOver <StoreLiteDto, StoreLiteDto> Filtering( IQueryOver <StoreLiteDto, StoreLiteDto> query, StoreGasStationOilDepotFilter filter) { query.IsLike(x => x.AZSNUMBER, filter.AzsNumber.ReplaceStar()); query.IsLike(x => x.AZSNAME, filter.AzsName.ReplaceStar()); query = query.OrderBy(x => x.AZSNUMBER).Asc; return(query); }
Filtering( IQueryOver <AttachedDocumentType, AttachedDocumentType> query, AttachedDocumentTypeFilter filter) { query.FindByRn(filter.Rn); query = query.OrderBy(x => x.Code).Asc; return(query); }
public IPagedList <ETag> Search(ETagSearchQuery query) { IQueryOver <ETag, ETag> queryOver = _session.QueryOver <ETag>(); if (!string.IsNullOrWhiteSpace(query.Name)) { queryOver = queryOver.Where(eTag => eTag.Name.IsInsensitiveLike(query.Name, MatchMode.Anywhere)); } return(queryOver.OrderBy(eTag => eTag.Name).Asc.Paged(query.Page)); }
public static IQueryOver <T, T> UseOrderByContext <T>(this IQueryOver <T, T> obj, IOrderBy <T> orderByContext) { if (orderByContext == null) { return(obj); } foreach (var item in orderByContext.OrderByList) { if (item.Item1 == OrderDirection.Asc) { obj.OrderBy(item.Item2).Asc(); } else { obj.OrderBy(item.Item2).Desc(); } } return(obj); }
public override IQueryOver <PermissionMaterialUser, PermissionMaterialUser> Filtering (IQueryOver <PermissionMaterialUser, PermissionMaterialUser> query, PermissionMaterialUserFilter filter) { query.FindByRn(filter.Rn); if (filter.PermissionMaterial.Rn > 0) { query.Where(x => x.PermissionMaterial.Rn == filter.PermissionMaterial.Rn); } return(query.OrderBy(x => x.Fullname).Asc()); }
public static IQueryOver <MediaCategory, MediaCategory> OrderBy( this IQueryOver <MediaCategory, MediaCategory> query, MediaCategorySortMethod sortBy) { switch (sortBy) { case MediaCategorySortMethod.CreatedOnDesc: return(query.OrderBy(category => category.CreatedOn).Desc); case MediaCategorySortMethod.CreatedOn: return(query.OrderBy(category => category.CreatedOn).Asc); case MediaCategorySortMethod.Name: return(query.OrderBy(category => category.Name).Asc); case MediaCategorySortMethod.NameDesc: return(query.OrderBy(category => category.Name).Desc); case MediaCategorySortMethod.DisplayOrderDesc: return(query.OrderBy(category => category.DisplayOrder).Desc); case MediaCategorySortMethod.DisplayOrder: return(query.OrderBy(category => category.DisplayOrder).Asc); default: throw new ArgumentOutOfRangeException("sortBy"); } }
private IQueryOver <Artist, Artist> AddOrder(IQueryOver <Artist, Artist> criteria, ArtistSortRule sortRule, ContentLanguagePreference languagePreference) { switch (sortRule) { case ArtistSortRule.Name: return(FindHelpers.AddNameOrder(criteria, languagePreference)); case ArtistSortRule.AdditionDate: return(criteria.OrderBy(a => a.CreateDate).Desc); } return(criteria); }
public override IQueryOver <UnitOfMeasure, UnitOfMeasure> Filtering(IQueryOver <UnitOfMeasure, UnitOfMeasure> query, UnitOfMeasureFilter filter) { query.FindByRn(filter.Rn); if (!string.IsNullOrWhiteSpace(filter.Code)) { query.Where(x => x.Code == filter.Code); } query = query.OrderBy(x => x.Code).Asc; return(query); }
private static IQueryOver<Item, Item> AddSortingCriterias(PagedEntityListFilterDto filter, IQueryOver<Item, Item> query) { IQueryOverOrderBuilder<Item, Item> builder = null; switch (filter.Column) { case "Id": builder = query.OrderBy(x => x.Id); break; case "Name": builder = query.OrderBy(x => x.Name); break; case "SerialNumber": builder = query.OrderBy(x => x.SerialNumber); break; case "CreatedOn": builder = query.OrderBy(x => x.CreatedOn); break; case "ModifiedOn": builder = query.OrderBy(x => x.ModifiedOn); break; } if (builder != null) { query = filter.AscendingOrder ? builder.Asc : builder.Desc; } return query; }
private static IQueryOver<User, User> AddSortingCriterias(PagedEntityListFilterDto filter, IQueryOver<User, User> query) { IQueryOverOrderBuilder<User, User> builder = null; switch (filter.Column) { case "Id": builder = query.OrderBy(x => x.Id); break; case "UserName": builder = query.OrderBy(x => x.UserName); break; case "LastName": builder = query.OrderBy(x => x.LastName); break; case "LastLogin": builder = query.OrderBy(x => x.LastLogin); break; } if (builder != null) { query = filter.AscendingOrder ? builder.Asc : builder.Desc; } return query; }
private static IQueryOver<Webpage, Webpage> ApplySort(DocumentMetadata metaData, IQueryOver<Webpage, Webpage> query) { switch (metaData.SortBy) { case SortBy.DisplayOrder: query = query.OrderBy(webpage => webpage.DisplayOrder).Asc; break; case SortBy.DisplayOrderDesc: query = query.OrderBy(webpage => webpage.DisplayOrder).Desc; break; case SortBy.PublishedOn: query = query.OrderBy(Projections.Conditional(Restrictions.IsNull(Projections.Property<Webpage>(x => x.PublishOn)), Projections.Constant(1), Projections.Constant(0))).Desc.ThenBy(webpage => webpage.PublishOn) .Asc; break; case SortBy.PublishedOnDesc: query = query.OrderBy(Projections.Conditional(Restrictions.IsNull(Projections.Property<Webpage>(x => x.PublishOn)), Projections.Constant(1), Projections.Constant(0))).Desc.ThenBy(webpage => webpage.PublishOn) .Desc; break; case SortBy.CreatedOn: query = query.OrderBy(webpage => webpage.CreatedOn).Asc; break; case SortBy.CreatedOnDesc: query = query.OrderBy(webpage => webpage.CreatedOn).Desc; break; default: throw new ArgumentOutOfRangeException(); } return query; }