示例#1
0
        public static IEnumerable <EFTypes.IndexedFile> GetPage(TaggerDbContext dbContext, ProcessedInput userQuery, int itemsPerPage)
        {
            var page = Math.Max(1, userQuery.Page);

            return
                (Filter(dbContext, userQuery)
                 .Skip(itemsPerPage * (page - 1))
                 .Take(itemsPerPage)
                 .AsEnumerable());
        }
示例#2
0
        private static IQueryable <EFTypes.IndexedFile> Filter(TaggerDbContext dbContext, ProcessedInput userQuery)
        {
            var idsMatchingIncludeCriteria = FileIdsMatchingCriteria(dbContext, userQuery.IncludeTerms, Enumerable.All);
            var idsMatchingExcludeCriteria = FileIdsMatchingCriteria(dbContext, userQuery.ExcludeTerms, Enumerable.Any);

            return(dbContext.FileRecords
                   .Include(fileRec => fileRec.FileTagPairs)
                   .Where(fileRec => userQuery.IncludeTerms.Count == 0 ? true : idsMatchingIncludeCriteria.Contains(fileRec.Id))
                   .Where(fileRec => !idsMatchingExcludeCriteria.Contains(fileRec.Id)));
        }