public PagedQueryResult <ClashNameModel> Search(ClashSearchQueryModel queryModel) { lock (_session) { var where = new List <Expression <Func <Clash_BySearch.IndexedFields, bool> > >(); if (!string.IsNullOrWhiteSpace(queryModel.NameOrRef)) { var termsList = queryModel.NameOrRef.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); where.AddRange(termsList.Select( term => (Expression <Func <Clash_BySearch.IndexedFields, bool> >)(p => p.TokenizedName .StartsWith(term)))); } var items = DocumentSessionExtensions .GetAll <Clash_BySearch.IndexedFields, Clash_BySearch, ClashTransformer_BySearch, ClashNameModel>(_session, where.Any() ? where.AggregateAnd() : null, out int totalResult, null, null, queryModel.Skip, queryModel.Top); return(new PagedQueryResult <ClashNameModel>(totalResult, items)); } }
protected CallMethodResult Search(string nameOrRef) { var queryModel = new ClashSearchQueryModel { NameOrRef = nameOrRef }; var res = Repository.Search(queryModel); TestContext.LastOperationCount = res?.Items?.Count ?? 0; TestContext.LastCollectionResult = res?.Items; TestContext.LastSingleResult = TestContext.LastOperationCount == 1 ? res.Items.First() : null; return(CallMethodResult.CreateHandled()); }
public PagedQueryResult <ClashNameModel> Search(ClashSearchQueryModel queryModel) { if (queryModel == null) { throw new ArgumentNullException(nameof(queryModel)); } var query = _dbContext.Query <Entities.Tenant.Clash>(); if (!string.IsNullOrWhiteSpace(queryModel.NameOrRef)) { var searchCondition = _searchConditionBuilder.StartAllWith(queryModel.NameOrRef.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)).Build(); query = query.Where(p => EF.Functions.Contains(EF.Property <string>(p, Entities.Tenant.Clash.SearchField), searchCondition)); } return(new PagedQueryResult <ClashNameModel>(query.Count(), query.ApplyPaging(queryModel.Skip, queryModel.Top).ProjectTo <ClashNameModel>(_mapper.ConfigurationProvider).ToList())); }
public IHttpActionResult Get([FromUri] ClashSearchQueryModel queryModel) { if (!ModelState.IsValid) { return(this.Error().InvalidParameters("One or more of the required query parameters are missing.")); } if (queryModel == null) { queryModel = new ClashSearchQueryModel(); } var clashes = _clashRepository.Search(queryModel); var searchModel = new SearchResultModel <ClashNameModel> { Items = clashes.Items.ToList(), TotalCount = clashes.TotalCount }; return(Ok(searchModel)); }
public PagedQueryResult <ClashNameModel> Search(ClashSearchQueryModel queryModel) => throw new NotImplementedException();