Beispiel #1
0
        public IQueryable <Notes> GetAllNotesUnderDirectory_Query(int directoryId)
        {
            var childDirectoryIds = _directoryService.GetAllChildDirectoriesQuery(directoryId)
                                    .Select(d => d.TagId);

            return(_relationshipService.GetAllTagNoteRelationshipsQuery()
                   .Where(tr => childDirectoryIds.Contains(tr.TagId) || tr.TagId == directoryId)
                   //.Select(tr => tr.Note)
                   .GroupBy(g => g.NoteId)
                   .Select(g => g.Select(tr => tr.Note).FirstOrDefault()));

            return(_relationshipService.GetAllTagNoteRelationshipsQuery()
                   .Where(tr => childDirectoryIds.Contains(tr.TagId) || tr.TagId == directoryId)
                   .Select(tr => tr.Note));
        }