public async Task <SearchResult <HumanTaskDefinitionAggregate> > Search(SearchHumanTaskDefParameter parameter, CancellationToken token) { IQueryable <HumanTaskDefinitionAggregate> result = _humanTaskDBContext.HumanTaskDefinitions .Include(_ => _.OperationParameters) .Include(_ => _.PresentationElements) .Include(_ => _.DeadLines).ThenInclude(_ => _.Escalations).ThenInclude(_ => _.ToParts) .Include(_ => _.PresentationParameters) .Include(_ => _.PeopleAssignments); if (!string.IsNullOrWhiteSpace(parameter.Name)) { result = result.Where(_ => _.Name == parameter.Name); } if (MAPPING_HUMANTASKDEF_TO_PROPERTYNAME.ContainsKey(parameter.OrderBy)) { result = result.InvokeOrderBy(MAPPING_HUMANTASKDEF_TO_PROPERTYNAME[parameter.OrderBy], parameter.Order); } int totalLength = await result.CountAsync(token); result = result.Skip(parameter.StartIndex).Take(parameter.Count); var content = await result.ToListAsync(token); return(new SearchResult <HumanTaskDefinitionAggregate> { StartIndex = parameter.StartIndex, Count = parameter.Count, TotalLength = totalLength, Content = content }); }
public Task <SearchResult <HumanTaskDefinitionAggregate> > Search(SearchHumanTaskDefParameter parameter, CancellationToken token) { IQueryable <HumanTaskDefinitionAggregate> result = _humanTaskDefs.AsQueryable(); if (!string.IsNullOrWhiteSpace(parameter.Name)) { result = result.Where(_ => _.Name == parameter.Name); } if (MAPPING_HUMANTASKDEF_TO_PROPERTYNAME.ContainsKey(parameter.OrderBy)) { result = result.InvokeOrderBy(MAPPING_HUMANTASKDEF_TO_PROPERTYNAME[parameter.OrderBy], parameter.Order); } int totalLength = result.Count(); result = result.Skip(parameter.StartIndex).Take(parameter.Count); return(Task.FromResult(new SearchResult <HumanTaskDefinitionAggregate> { StartIndex = parameter.StartIndex, Count = parameter.Count, TotalLength = totalLength, Content = result.ToList() })); }