protected virtual IDictionary <string, string> GetObjectIds(string[] taggedItemIds) { var searchCriteria = new TaggedItemSearchCriteria { Ids = taggedItemIds, Take = int.MaxValue }; var searchResult = _taggedItemSearchService.SearchTaggedItems(searchCriteria); var result = searchResult.Results.ToDictionary(e => e.Id, e => e.EntityId); return(result); }
public GenericSearchResult <TaggedItem> SearchTaggedItems(TaggedItemSearchCriteria criteria) { var retVal = new GenericSearchResult <TaggedItem>(); using (var repository = _repositoryFactory()) { var query = repository.TaggedItems; if (!string.IsNullOrWhiteSpace(criteria.EntityId)) { query = query.Where(x => x.ObjectId == criteria.EntityId); } if (!string.IsNullOrWhiteSpace(criteria.EntityType)) { query = query.Where(x => x.ObjectType == criteria.EntityType); } if (!criteria.Ids.IsNullCollection()) { query = query.Where(x => criteria.Ids.Contains(x.Id)); } if (criteria.ChangedFrom.HasValue) { query = query.Where(x => x.ModifiedDate.HasValue && x.ModifiedDate.Value.Date >= criteria.ChangedFrom.Value.Date); } var sortInfos = criteria.SortInfos; if (sortInfos.IsNullOrEmpty()) { sortInfos = new[] { new SortInfo { SortColumn = ReflectionUtility.GetPropertyName <TaggedItem>(x => x.Label) } }; } query = query.OrderBySortInfos(sortInfos); retVal.TotalCount = query.Count(); query = query.Skip(criteria.Skip).Take(criteria.Take); var ids = query.Select(x => x.Id).ToArray(); retVal.Results = GetTaggedItemsByIds(ids).AsQueryable().OrderBySortInfos(sortInfos).ToList(); } return(retVal); }