public IQueryable <vw_Documents> GetDocuments(int CaseID, long?SessionID, Guid?ParentFolder = null) { Guid FolderID; if (ParentFolder.HasValue) { FolderID = ParentFolder.Value; } else { FolderID = FoldersRepository.GetParentFolderID(CaseID, SessionID); } return(DocumentsRepository.GetDocuments(CaseID, SessionID).Where(p => p.FolderID == FolderID)); }