protected IFileObject[] ApplySortAndPaging(Query q, IFileObject[] files) { if (q.Sort != null) { if (q.Sort.Length > 1) { throw new Exception("FileSystemDalc doesn't support sorting by multiple fields"); } var qSortFld = new QSort(q.Sort[0]); files = files.OrderBy(f => GetFileObjectField(qSortFld.Field, f)).ToArray(); if (qSortFld.SortDirection == System.ComponentModel.ListSortDirection.Descending) { Array.Reverse(files); } } var folders = files.Where(f => f.Type == FileType.Folder); var onlyFiles = files.Where(f => f.Type == FileType.File); return(folders.Union(onlyFiles).Skip(q.StartRecord).Take(q.RecordCount).ToArray()); }
public virtual string BuildSort(QSort value) { var sortFld = BuildValue((IQueryValue)value.Field); return(String.Format("{0} {1}", sortFld, value.SortDirection == ListSortDirection.Ascending ? QSort.Asc : QSort.Desc)); }