protected override IQueryOver <Desk, Desk> DecorateCriteria(IQueryOver <Desk, Desk> queryOver) { DeskDocumentEndorsement deskDocumentEndorsement = null; DeskRoleUser deskRoleUser = null; DeskDocumentVersion deskDocumentVersion = null; DeskDocument deskDocument = null; queryOver.JoinAlias(o => o.DeskDocuments, () => deskDocument) .JoinAlias(() => deskDocument.DeskDocumentVersions, () => deskDocumentVersion) .JoinAlias(o => o.DeskRoleUsers, () => deskRoleUser) .Left.JoinAlias(() => deskRoleUser.DeskDocumentEndorsements, () => deskDocumentEndorsement, () => deskDocumentEndorsement.DeskDocumentVersion.Id == deskDocumentVersion.Id); if (DeskId.HasValue) { queryOver.Where(desk => desk.Id == DeskId.Value); } FilterByUserPermission(queryOver); queryOver.SelectList(select => select.SelectGroup(() => deskDocument.Id).SelectMax(() => deskDocumentVersion.Version)); if (!VersionFilters.Any()) { return(queryOver); } foreach (KeyValuePair <Guid, decimal> versionFilter in VersionFilters) { queryOver.Where(() => deskDocument.Id == versionFilter.Key) .And(() => deskDocumentVersion.Version == versionFilter.Value); } return(queryOver); }
/// <summary> /// Aggiunge ulteriori filtri alla lista già presente per l'attuale queryOver. /// </summary> /// <param name="queryOver">QueryOver a cui agganciare il filtro</param> /// <returns>True se esistono criteri da agganciare, False altrimenti</returns> protected virtual bool AttachFilterExpressions(ref IQueryOver <T, T> queryOver) { if (this.FilterExpressions == null && this.CriteriaFilterExpressions == null) { return(false); } try { foreach (Expression <Func <T, bool> > c in this.FilterExpressions) { queryOver.Where(c); } foreach (ICriterion c in this.CriteriaFilterExpressions) { queryOver.Where(c); } } catch (Exception ex) { throw new DocSuiteException("Errore filtro", "Espressione di filtro non corretta", ex); } return(true); }
/// <summary> /// Crea i criteri base per l'interrogazione /// </summary> /// <param name="queryOver"></param> /// <returns></returns> protected override IQueryOver <PECMailLog, PECMailLog> DecorateCriteria(IQueryOver <PECMailLog, PECMailLog> queryOver) { if (PECMail != null) { queryOver.Where(x => x.Mail == PECMail); } if (PECMailIDIn != null && PECMailIDIn.Count > 0) { queryOver.AndRestrictionOn(x => x.Id).IsIn(PECMailIDIn); } if (!string.IsNullOrEmpty(LogType)) { queryOver.Where(x => x.Type == LogType); } if (!string.IsNullOrEmpty(DescriptionLike)) { queryOver.WhereRestrictionOn(x => x.Description).IsInsensitiveLike(DescriptionLike, MatchMode.Anywhere); } innerDateTimeRange(); if (DateFrom.HasValue) { queryOver.Where(x => x.Date > DateFrom); } if (DateTo.HasValue) { queryOver.Where(x => x.Date < DateTo.Value.AddDays(1).AddSeconds(-1)); } return(queryOver); }
private IQueryOver <Quota, Quota> ObtemQueryOverComFiltrosAplicados(RelatorioAgendamentoFiltroVm filtro) { IQueryOver <Quota, Quota> queryOver = _quotas.GetQueryOver(); if (filtro.DataDe.HasValue) { queryOver = queryOver.Where(x => x.Data >= filtro.DataDe.Value); } if (filtro.DataAte.HasValue) { queryOver = queryOver.Where(x => x.Data <= filtro.DataAte.Value); } if (filtro.CodigoFluxoDeCarga.HasValue) { queryOver = queryOver.Where(x => x.FluxoDeCarga == (Enumeradores.FluxoDeCarga) Enum.Parse(typeof(Enumeradores.FluxoDeCarga), Convert.ToString(filtro.CodigoFluxoDeCarga.Value))); } if (!string.IsNullOrEmpty(filtro.CodigoFornecedor)) { queryOver = queryOver.Where(x => x.Fornecedor.Codigo == filtro.CodigoFornecedor); } queryOver = queryOver.Where(x => x.CodigoTerminal == filtro.CodigoTerminal); return(queryOver); }
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)); }
private static IQueryOver <Entities.PersistedGrant, Entities.PersistedGrant> ApplyPersistentGrantFilter( IQueryOver <Entities.PersistedGrant, Entities.PersistedGrant> query, PersistedGrantFilter filter) { if (!string.IsNullOrWhiteSpace(filter.SubjectId)) { query.Where(grant => grant.SubjectId == filter.SubjectId); } if (!string.IsNullOrWhiteSpace(filter.SessionId)) { query.Where(grant => grant.SubjectId == filter.SubjectId); } if (!string.IsNullOrWhiteSpace(filter.ClientId)) { query.Where(grant => grant.ClientId == filter.SubjectId); } if (!string.IsNullOrWhiteSpace(filter.Type)) { query.Where(grant => grant.Type == filter.Type); } return(query); }
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)); }
private IEnumerable <Webpage> GetWebpageCopies(Site @from, Site to, SiteCloneContext siteCloneContext, Webpage fromParent = null, Webpage toParent = null) { IQueryOver <Webpage, Webpage> queryOver = _session.QueryOver <Webpage>().Where(webpage => webpage.Site.Id == @from.Id); queryOver = fromParent == null ? queryOver.Where(webpage => webpage.Parent == null) : queryOver.Where(webpage => webpage.Parent.Id == fromParent.Id); IList <Webpage> webpages = queryOver.List(); foreach (Webpage webpage in webpages) { Webpage copy = webpage.GetCopyForSite(to); siteCloneContext.AddEntry(webpage, copy); copy.Parent = toParent; yield return(copy); foreach (Webpage child in GetWebpageCopies(@from, to, siteCloneContext, webpage, copy)) { yield return(child); } } }
/// <summary> /// Добавляет в запрос поиска по батчам условие /// </summary> /// <param name="criteria"> /// The criteria. /// </param> /// <param name="query"> /// The query. /// </param> /// <returns> /// The <see cref="IQueryOver"/>. /// </returns> private IQueryOver <Batch, Batch> AddWhereCondition( SearchExportSmoBatchCriteria criteria, IQueryOver <Batch, Batch> query) { // Выбираем по периоду query.Where(x => x.Period.Id == criteria.PeriodId); // Выбираем по отправителю if (criteria.SenderId != Guid.Empty) { query.Where(x => x.Sender.Id == criteria.SenderId); } // Выбираем по получателю if (criteria.ReceiverId != Guid.Empty) { query.Where(x => x.Receiver.Id == criteria.ReceiverId); } // Выбираем по номеру батча if (criteria.BatchNumber != -1) { query.Where(x => x.Number == criteria.BatchNumber); } return(query); }
public override IQueryOver <Contractor, Contractor> Filtering( IQueryOver <Contractor, Contractor> query, UserFilter filter) { query.FindByRn(filter.Rn); if (!string.IsNullOrWhiteSpace(filter.TableNumber)) { query.IsLike(x => x.ClockNumber, filter.TableNumber.ReplaceStar(string.Empty)); } if (filter.TypeCatalog > 0) { query.Where(x => x.Catalog.Rn == (long)filter.TypeCatalog); } if (filter.IsWorker) { query.Where(Restrictions.Eq(Projections.SqlFunction("length", NHibernateUtil.String, Projections.Property <Contractor>(x => x.ClockNumber)), 6)); } query.IsLike(x => x.Family, filter.Lastname.ReplaceStar(string.Empty)); query.IsLike(x => x.Firstname, filter.Firstname.ReplaceStar(string.Empty)); query.IsLike(x => x.Name, filter.OrganizationName.ReplaceStar(string.Empty)); query.IsLike(x => x.NameShort, filter.NameShort.ReplaceStar(string.Empty)); return(query); }
public string GetConcatenatedPhoneNumberString(SMSLeads Mode) { IQueryOver <Enrollee, Enrollee> query = _session.QueryOver <Enrollee>().Where(x => x.Isexpundged == false && x.IsDeleted == false); query.Where(Restrictions.Gt( Projections.SqlFunction("length", NHibernateUtil.String, Projections.Property <Enrollee>(b => b.Mobilenumber)), 9 )); switch (Mode) { case SMSLeads.OnlyPrincipal: query.Where(x => x.Parentid < 1); break; } string response = string.Empty; foreach (Enrollee item in query.List <Enrollee>()) { if (!response.Contains(item.Mobilenumber)) { response = response + "," + item.Mobilenumber; } } return(response); }
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)); }
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()); }
private IQueryOver <Desk, Desk> FilterBySearchField(IQueryOver <Desk, Desk> queryOver) { try { // Filtro sul nome del tavolo if (!string.IsNullOrEmpty(DeskName)) { queryOver.WhereRestrictionOn(x => x.Name).IsLike(DeskName, MatchMode.Anywhere); } if (!string.IsNullOrEmpty(DeskDescription)) { queryOver.WhereRestrictionOn(x => x.Description).IsLike(DeskDescription, MatchMode.Anywhere); } if (DeskNotExprired) { queryOver.Where(x => x.ExpirationDate >= new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 0, 0, 0)); } if (DeskContainerId != default(int)) { queryOver.Where(desk => container.Id == DeskContainerId); } } catch (Exception ex) { throw new DocSuiteException("Errore in FilterByUserPermission", ex); } return(queryOver); }
Filtering(IQueryOver <ActSelectionOfProbeLiteDto, ActSelectionOfProbeLiteDto> query, ActSelectionOfProbeFilter filter) { query.FindByRn(filter.Rn); if (filter.CertificateQualityFilter.NomerCertificata != null) { query.Where(x => x.NumbCertificate == filter.CertificateQualityFilter.NomerCertificata); } if (filter.CertificateQualityFilter.Cast != null) { query.Where(x => x.Cast == filter.CertificateQualityFilter.Cast); } if (filter.RnDepartmentCreator > 0) { query.Where(x => x.RnDepartmentCreator == filter.RnDepartmentCreator); } if (filter.CreationDate.From != null || filter.CreationDate.To != null) { query.IsBetween(x => x.CreationDate, filter.CreationDate); } 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); }
/// <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 <Acatalog, Acatalog> Filtering(IQueryOver <Acatalog, Acatalog> query, AcatalogFilter filter) { if (!string.IsNullOrEmpty(filter.Name)) { query.WhereRestrictionOn(x => x.Name).IsLike(filter.Name); } if (filter.SectionOfSystem != null && !string.IsNullOrWhiteSpace(filter.SectionOfSystem.UnitCode)) { query.JoinQueryOver(x => x.SectionOfSystem, JoinType.LeftOuterJoin) .Where(x => x.Rn == filter.SectionOfSystem.UnitCode); } if (filter.UserPrivilege != null) { UserPrivilege userPrivilegeALias = null; query.JoinAlias(x => x.UserPrivileges, () => userPrivilegeALias); query.JoinQueryOver(() => userPrivilegeALias.Role, JoinType.InnerJoin); if (filter.UserPrivilege.Role != null) { if (filter.UserPrivilege.Role.Rn != 0) { query.Where(() => userPrivilegeALias.Role.Rn == filter.UserPrivilege.Role.Rn); } if (filter.UserPrivilege.Role.UserRoles != null) { UserRole userRoleAlias = null; query.JoinAlias(() => userPrivilegeALias.Role.UserRoles, () => userRoleAlias) .EqualsUser(x => userRoleAlias.UserList.AUTHID); // var fil = Restrictions.EqProperty( // Projections.SqlFunction("User", NHibernateUtil.String), // Projections.Property<UserRole>(x => userRoleAlias.UserList.AUTHID)); // query.Where(fil); } } if (filter.UserPrivilege.UnitFunction != null) { UnitFunction unitfuncAlias = null; query.JoinAlias(() => userPrivilegeALias.UnitFunctions, () => unitfuncAlias); query.Where(x => unitfuncAlias.Standard == filter.UserPrivilege.UnitFunction.Standard); if (filter.UserPrivilege.UnitFunction.SectionOfSystemUnitcode != null) { query.JoinQueryOver(() => unitfuncAlias.SectionOfSystemUnitcode, JoinType.InnerJoin); if (!string.IsNullOrWhiteSpace(filter.UserPrivilege.UnitFunction.SectionOfSystemUnitcode.UnitCode)) { query.Where(x => unitfuncAlias.SectionOfSystemUnitcode.Rn == filter.UserPrivilege.UnitFunction.SectionOfSystemUnitcode.UnitCode); } } } } return(query); }
private IQueryOver <DeskStoryBoard, DeskStoryBoard> SetDeskIdFilter(IQueryOver <DeskStoryBoard, DeskStoryBoard> queryOver) { queryOver.Where(() => desk.Id == this.DeskId); if (!FindDocumentComments) { queryOver.Where(x => x.DeskDocumentVersion == null); } return(queryOver); }
private IQueryOver <BatchRunResult, BatchRunResult> GetResultsQuery(BatchRun batchRun) { IQueryOver <BatchRunResult, BatchRunResult> queryOver = _session.QueryOver <BatchRunResult>(); if (batchRun != null) { return(queryOver.Where(result => result.BatchRun.Id == batchRun.Id)); } // query to return 0; return(queryOver.Where(result => result.Id < 0)); }
/// <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 <EmployeeDto, EmployeeDto> Filtering( IQueryOver <EmployeeDto, EmployeeDto> query, EmployeeFilter filter) { var tmp = filter.Fullname.Replace("*", "%").ToUpper(); query.Where(Restrictions.Like(Projections.SqlFunction("upper", NHibernateUtil.String, Projections.Property <EmployeeDto>(x => x.Fullname)), tmp)); query = query.Where(x => x.Iswork == 1) .OrderBy(x => x.Fullname).Asc; return(query); }
public override IQueryOver <CertificateQuality, CertificateQuality> Filtering( IQueryOver <CertificateQuality, CertificateQuality> query, CertificateQualityFilter filter) { query.FindByRn(filter.Rn); query.IsBetween(x => x.CreationDate, filter.CreationDate); query.IsBetween(x => x.StorageDate, filter.StorageDate); query.IsBetween(x => x.MakingDate, filter.MakingDate); query.IsLike(x => x.StandardSize, filter.StandardSize.ReplaceStar()); query.IsLike(x => x.NomerCertificata, filter.NomerCertificata.ReplaceStar()); query.IsLike(x => x.ModeThermoTreatment, filter.ModeThermoTreatment.ReplaceStar()); query.IsLike(x => x.Mix, filter.Mix.ReplaceStar()); query.IsLike(x => x.Marka, filter.Marka.ReplaceStar()); query.IsLike(x => x.GostMix, filter.GostMix.ReplaceStar()); query.IsLike(x => x.GostMarka, filter.GostMarka.ReplaceStar()); query.IsLike(x => x.FullRepresentation, filter.FullRepresentation.ReplaceStar()); query.IsLike(x => x.DeliveryCondition, filter.DeliveryCondition.ReplaceStar()); query.IsLike(x => x.Cast, filter.Cast.ReplaceStar()); query.IsIn(x => x.State, filter.State); if (filter.UserCreator != null) { query.Where(x => x.UserCreator.Rn == filter.UserCreator.Rn); } if (!string.IsNullOrWhiteSpace(filter.Pref)) { query.Where(x => x.Pref == filter.Pref); } if (filter.Numb != null) { query.Where(x => x.Numb == filter.Numb); } if (filter.CreatorFactory != null) { query.Where(x => x.CreatorFactory.Rn == filter.CreatorFactory.Rn); } if (filter.NomenclatureNumber != null) { query.JoinQueryOver(x => x.PlanCertificate, JoinType.LeftOuterJoin); NomenclatureNumberModification nommodifAlias = null; query.JoinAlias(x => x.PlanCertificate.ModificationNomenclature, () => nommodifAlias, JoinType.LeftOuterJoin); query.Where(x => nommodifAlias.Code == filter.NomenclatureNumber.Code); } return(query); }
protected override void SetupWhere(IQueryOver <UserEntity, UserEntity> queryOver, UserQuery request) { if (!string.IsNullOrEmpty(request.UserName)) { queryOver = queryOver.Where(Restrictions.InsensitiveLike(Projections.Property(() => RootAlias.UserName), request.UserName, MatchMode.Anywhere)); } if (!string.IsNullOrEmpty(request.InGameName)) { queryOver = queryOver.Where(Restrictions.InsensitiveLike( Projections.Property(() => RootAlias.InGameName), request.InGameName, MatchMode.Anywhere)); } }
public IQueryOver <T, T> BuildZustandsabschnittBaseFilter <T>(IQueryOver <T, T> source) where T : ZustandsabschnittBase { if (Parameter.ZustandsindexVon.HasValue) { source = source.Where(za => za.Zustandsindex >= Parameter.ZustandsindexVon.Value); } if (Parameter.ZustandsindexBis.HasValue) { source = source.Where(za => za.Zustandsindex <= Parameter.ZustandsindexBis.Value); } return(source); }
protected override IQueryOver <Desk, Desk> DecorateCriteria(IQueryOver <Desk, Desk> queryOver) { if (IsOpen.HasValue && IsOpen.Value) { queryOver = queryOver.Where(q => q.Status.Value == DeskState.Open); } if (DeskStates.Count > 0) { queryOver = queryOver.Where(q => q.Status.IsIn(DeskStates.ToList())); } queryOver = FilterByUserPermission(queryOver); queryOver = FilterBySearchField(queryOver); return(queryOver); }
public IQueryOver <KoordinierteMassnahmeGIS, KoordinierteMassnahmeGIS> BuildFilter(IQueryOver <KoordinierteMassnahmeGIS, KoordinierteMassnahmeGIS> source) { if (Parameter.AusfuehrungsanfangVon.HasValue) { source = source.Where(km => km.AusfuehrungsAnfang >= Parameter.AusfuehrungsanfangVon.Value); } if (Parameter.AusfuehrungsanfangBis.HasValue) { source = source.Where(km => km.AusfuehrungsAnfang <= Parameter.AusfuehrungsanfangBis.Value); } return(source); }
// Implementacja właściwa dla modelu grupy. public override void ApplyToQuery(IQueryOver <GroupModel, GroupModel> query) { _filterProperties.TryGetValue("GroupId", out var idValue); _filterProperties.TryGetValue("Name", out var name); if (int.Parse(idValue) > 0) { query.Where(g => g.GroupId == int.Parse(idValue)); } if (!String.IsNullOrEmpty(name)) { query.Where(g => g.Name == name); } }
/// <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 <ContractLiteDto, ContractLiteDto> Filtering( IQueryOver <ContractLiteDto, ContractLiteDto> query, ContractFilter filter) { query.FindByRn(filter.Rn); if (filter.Contaractor != null) { query.Where(x => x.ContractorAgentMemo == filter.Contaractor.TableNumber); } query.Where(x => x.State == filter.State); return(query); }
public IList <BasicTraffic> GetAllBaiscTrafficsByConditions(TrafficTransferMode TTM, decimal machineID, DateTime fromDate, DateTime toDate, int fromTime, int toTime, int fromRecord, int toRecord, decimal fromIdentifier, decimal toIdentifier, bool IsIntegralConditions) { IList <BasicTraffic> BasicTrafficsList = null; IEnumerable <BasicTraffic> BasicTrafficEnumerable = null; IQueryOver <BasicTraffic, BasicTraffic> IQueryOverBasicTraffic = null; Expression <Func <BasicTraffic, bool> > conditions = conditions = x => x.Date >= fromDate && x.Date <= toDate && x.Time >= fromTime && x.Time <= toTime && x.Active == true; switch (TTM) { case TrafficTransferMode.Normal: IQueryOverBasicTraffic = NHibernateSession.QueryOver <BasicTraffic>() .Where(conditions); BasicTrafficsList = this.GetBasicTrafficsOverMachine(machineID, IQueryOverBasicTraffic); break; case TrafficTransferMode.RecordBase: IQueryOverBasicTraffic = NHibernateSession.QueryOver <BasicTraffic>() .OrderBy(basicTraffic => basicTraffic.ID).Asc .Skip(fromRecord - 1) .Take(toRecord - fromRecord + 1) .Clone(); if (IsIntegralConditions) { IQueryOverBasicTraffic = IQueryOverBasicTraffic.Where(conditions); BasicTrafficsList = this.GetBasicTrafficsOverMachine(machineID, IQueryOverBasicTraffic); } else { BasicTrafficsList = IQueryOverBasicTraffic.List <BasicTraffic>(); } break; case TrafficTransferMode.IdentifierBase: IQueryOverBasicTraffic = NHibernateSession.QueryOver <BasicTraffic>() .Where(basicTraffic => basicTraffic.ID >= fromIdentifier && basicTraffic.ID <= toIdentifier && basicTraffic.Active) .Clone(); if (IsIntegralConditions) { IQueryOverBasicTraffic = IQueryOverBasicTraffic.Where(conditions); BasicTrafficsList = this.GetBasicTrafficsOverMachine(machineID, IQueryOverBasicTraffic); } else { BasicTrafficsList = BasicTrafficEnumerable.ToList <BasicTraffic>(); } break; } return(BasicTrafficsList); }
public static IQueryOver <E, F> WhereStringIsNotNullOrEmpty <E, F>(this IQueryOver <E, F> query, Expression <Func <E, object> > propExpression) { var prop = Projections.Property(propExpression); var criteria = Restrictions.Or(Restrictions.IsNull(prop), Restrictions.Eq(Projections.SqlFunction("trim", NHibernateUtil.String, prop), "")); return(query.Where(Restrictions.Not(criteria))); }
public IList <EnrolleePolicyName> GetEnrolleePolicyNumberName(string phrase) { IQueryOver <Enrollee, Enrollee> query = _session.QueryOver <Enrollee>().Where(x => x.IsDeleted == false); List <EnrolleePolicyName> response = new List <EnrolleePolicyName>(); if (!string.IsNullOrEmpty(phrase)) { //search policy number phrase = "%" + phrase + "%"; query = query.Where(Restrictions.On <Enrollee>(x => x.Policynumber).IsInsensitiveLike(phrase)); foreach (Enrollee item in query.List().OrderBy(x => x.Policynumber)) { EnrolleePolicyName itemo = new EnrolleePolicyName { Id = item.Id, Name = item.Surname + " " + item.Othernames, Policynumber = item.Policynumber, }; response.Add(itemo); } } return(response); }
protected virtual IQueryOver<PagesView, PagesView> FilterQuery(IQueryOver<PagesView, PagesView> query, PagesFilter request, Junction hasnotSeoDisjunction) { PageProperties alias = null; if (!request.IncludeArchived) { query = query.Where(() => !alias.IsArchived); } if (request.OnlyMasterPages) { query = query.Where(() => alias.IsMasterPage); } else if (!request.IncludeMasterPages) { query = query.Where(() => !alias.IsMasterPage); } if (!string.IsNullOrWhiteSpace(request.SearchQuery)) { var searchQuery = string.Format("%{0}%", request.SearchQuery); query = query.Where(Restrictions.Disjunction() .Add(Restrictions.InsensitiveLike(Projections.Property(() => alias.Title), searchQuery)) .Add(Restrictions.InsensitiveLike(Projections.Property(() => alias.PageUrl), searchQuery)) .Add(Restrictions.InsensitiveLike(Projections.Property(() => alias.MetaTitle), searchQuery)) .Add(Restrictions.InsensitiveLike(Projections.Property(() => alias.MetaDescription), searchQuery)) .Add(Restrictions.InsensitiveLike(Projections.Property(() => alias.MetaKeywords), searchQuery))); } if (request.LanguageId.HasValue) { if (request.LanguageId.Value.HasDefaultValue()) { query = query.Where(Restrictions.IsNull(Projections.Property(() => alias.Language.Id))); } else { query = query.Where(Restrictions.Eq(Projections.Property(() => alias.Language.Id), request.LanguageId.Value)); } } if (request.Tags != null) { foreach (var tagKeyValue in request.Tags) { var id = tagKeyValue.Key.ToGuidOrDefault(); query = query.WithSubquery.WhereExists(QueryOver.Of<PageTag>().Where(tag => tag.Tag.Id == id && tag.Page.Id == alias.Id).Select(tag => 1)); } } if (request.Categories != null) { var categories = request.Categories.Select(c => new Guid(c.Key)).Distinct().ToList(); foreach (var category in categories) { var childCategories = categoryService.GetChildCategoriesIds(category).ToArray(); query = query.WithSubquery.WhereExists(QueryOver.Of<PageCategory>().Where(cat => !cat.IsDeleted && cat.Page.Id == alias.Id).WhereRestrictionOn(cat => cat.Category.Id).IsIn(childCategories).Select(cat => 1)); } } if (request.Status.HasValue) { if (request.Status.Value == PageStatusFilterType.OnlyPublished) { query = query.Where(() => alias.Status == PageStatus.Published); } else if (request.Status.Value == PageStatusFilterType.OnlyUnpublished) { query = query.Where(() => alias.Status != PageStatus.Published); } else if (request.Status.Value == PageStatusFilterType.ContainingUnpublishedContents) { const ContentStatus draft = ContentStatus.Draft; Root.Models.Content contentAlias = null; var subQuery = QueryOver.Of<PageContent>() .JoinAlias(p => p.Content, () => contentAlias) .Where(pageContent => pageContent.Page.Id == alias.Id) .And(() => contentAlias.Status == draft) .And(() => !contentAlias.IsDeleted) .Select(pageContent => 1); query = query.WithSubquery.WhereExists(subQuery); } } if (request.SeoStatus.HasValue) { if (request.SeoStatus.Value == SeoStatusFilterType.HasNotSeo) { query = query.Where(hasnotSeoDisjunction); } else { query = query.Where(Restrictions.Not(hasnotSeoDisjunction)); } } if (!string.IsNullOrWhiteSpace(request.Layout)) { Guid id; var length = request.Layout.Length - 2; if (request.Layout.StartsWith("m-") && Guid.TryParse(request.Layout.Substring(2, length), out id)) { query = query.Where(() => alias.MasterPage.Id == id); } if (request.Layout.StartsWith("l-") && Guid.TryParse(request.Layout.Substring(2, length), out id)) { query = query.Where(() => alias.Layout.Id == id); } } if (request.ContentId.HasValue) { Root.Models.Content contentAlias = null; ChildContent childContentAlias = null; HtmlContent htmlContentAlias = null; PageContent pageContentAlias = null; var htmlChildContentSubQuery = QueryOver.Of(() => htmlContentAlias) .JoinAlias(h => h.ChildContents, () => childContentAlias) .Where(() => htmlContentAlias.Id == contentAlias.Id) .And(() => childContentAlias.Child.Id == request.ContentId.Value) .Select(pageContent => 1); var pageContentSubQuery = QueryOver.Of(() => pageContentAlias) .JoinAlias(() => pageContentAlias.Content, () => contentAlias) .And(() => pageContentAlias.Page.Id == alias.Id) .And(() => !contentAlias.IsDeleted) .And(() => !pageContentAlias.IsDeleted) .And(Restrictions.Or( Restrictions.Where(() => contentAlias.Id == request.ContentId.Value), Subqueries.WhereExists(htmlChildContentSubQuery) )) .Select(pageContent => 1); query = query.WithSubquery.WhereExists(pageContentSubQuery); } return query; }
private IQueryOver<ProductReview, ProductReview> GetBaseProductVariantReviewsQuery( IQueryOver<ProductReview, ProductReview> query, ProductVariant productVariant) { return query.Where(review => review.ProductVariant.Id == productVariant.Id && review.Approved == true); }
private static IQueryOver<Contact, Contact> ApplyInvalidNameFilter(IQueryOver<Contact, Contact> q1) { return q1.Where(x => x.Surname != null && x.Forename != null); }
private static IQueryOver<Recipes, Recipes> SearchByDiet( RecipeQuery query, IQueryOver<Recipes, Recipes> recipesQuery, RecipeMetadata metadata) { if (query.Diet.GlutenFree) { recipesQuery = recipesQuery.Where(() => metadata.DietGlutenFree); } if (query.Diet.NoAnimals) { recipesQuery = recipesQuery.Where(() => metadata.DietNoAnimals); } if (query.Diet.NoMeat) { recipesQuery = recipesQuery.Where(() => metadata.DietNomeat); } if (query.Diet.NoPork) { recipesQuery = recipesQuery.Where(() => metadata.DietNoPork); } if (query.Diet.NoRedMeat) { recipesQuery = recipesQuery.Where(() => metadata.DietNoRedMeat); } return recipesQuery; }
private static IQueryOver<Recipes, Recipes> SearchByHighResolutionPhotos( RecipeQuery query, IQueryOver<Recipes, Recipes> recipesQuery, RecipeMetadata metadata) { int highResolution = 1024 * 768; if (query.Photos == PhotoFilter.HighRes) { recipesQuery = recipesQuery.Where(() => metadata.PhotoRes >= highResolution); } return recipesQuery; }
private static IQueryOver<Recipes, Recipes> SearchByMeal( RecipeQuery query, IQueryOver<Recipes, Recipes> recipesQuery, RecipeMetadata metadata) { if (query.Meal != MealFilter.All) { if (query.Meal == MealFilter.Breakfast) { recipesQuery = recipesQuery.Where(() => metadata.MealBreakfast); } if (query.Meal == MealFilter.Dessert) { recipesQuery = recipesQuery.Where(() => metadata.MealDessert); } if (query.Meal == MealFilter.Dinner) { recipesQuery = recipesQuery.Where(() => metadata.MealDinner); } if (query.Meal == MealFilter.Lunch) { recipesQuery = recipesQuery.Where(() => metadata.MealLunch); } } return recipesQuery; }
private static IQueryOver<Recipes, Recipes> SearchByNutrition( RecipeQuery query, IQueryOver<Recipes, Recipes> recipesQuery, RecipeMetadata metadata) { if (query.Nutrition.LowCalorie) { recipesQuery = recipesQuery.Where(() => metadata.NutritionLowCalorie); } if (query.Nutrition.LowCarb) { recipesQuery = recipesQuery.Where(() => metadata.NutritionLowCarb); } if (query.Nutrition.LowFat) { recipesQuery = recipesQuery.Where(() => metadata.NutritionLowFat); } if (query.Nutrition.LowSodium) { recipesQuery = recipesQuery.Where(() => metadata.NutritionLowSodium); } if (query.Nutrition.LowSugar) { recipesQuery = recipesQuery.Where(() => metadata.NutritionLowSugar); } return recipesQuery; }
private static IQueryOver<Recipes, Recipes> SearchBySkill( RecipeQuery query, IQueryOver<Recipes, Recipes> recipesQuery, RecipeMetadata metadata) { if (query.Skill.Common) { recipesQuery = recipesQuery.Where(() => metadata.SkillCommon).OrderBy(() => metadata.Commonality).Desc(); } if (query.Skill.Easy) { recipesQuery = recipesQuery.Where(() => metadata.SkillEasy); } if (query.Skill.Quick) { recipesQuery = recipesQuery.Where(() => metadata.SkillQuick); } return recipesQuery; }
private static IQueryOver<Recipes, Recipes> SearchByTaste( RecipeQuery query, IQueryOver<Recipes, Recipes> recipesQuery, RecipeMetadata metadata) { if (query.Taste.MildToSpicy != SpicinessLevel.Medium) { recipesQuery = query.Taste.MildToSpicy < SpicinessLevel.Medium ? recipesQuery.Where(() => metadata.TasteMildToSpicy <= query.Taste.Spiciness) .OrderBy(() => metadata.TasteMildToSpicy) .Asc() : recipesQuery.Where(() => metadata.TasteMildToSpicy >= query.Taste.Spiciness) .OrderBy(() => metadata.TasteMildToSpicy) .Desc(); } if (query.Taste.SavoryToSweet != SweetnessLevel.Medium) { recipesQuery = query.Taste.SavoryToSweet < SweetnessLevel.Medium ? recipesQuery.Where(() => metadata.TasteSavoryToSweet <= query.Taste.Sweetness) .OrderBy(() => metadata.TasteSavoryToSweet) .Asc() : recipesQuery.Where(() => metadata.TasteSavoryToSweet >= query.Taste.Sweetness) .OrderBy(() => metadata.TasteSavoryToSweet) .Desc(); } return recipesQuery; }