Hi,
I have 4 tables in my database:
1 - ProjectFile
2 - DocumentType
3 - DocumentCategory
4 - ProjectFileVersions
ProjectFile has a relation to DocumentType, which has a relation to DocumentCategory.
Im trying to get my data organized that I can get all ProjectFiles for a specific project and sorted on:
- Document Category Identifier (this can range A - M)
then within those there will be multiple types which i also want to sort on
- Document Type Identifier (this can range A01 - A07)
then also I want to sort the various FileVersions sorted on their Version.
I came up with the following code:
public static ProjectFileCollection GetFilesForOverview(Guid ProjectID)
{
ProjectFileCollection ProjectFiles = new ProjectFileCollection();
// Define sorters
ISortExpression DocumentCategorySorter = new SortExpression();
DocumentCategorySorter.Add(DocumentCategoryFields.Identifier | SortOperator.Ascending);
ISortExpression DocumentTypeSorter = new SortExpression();
DocumentTypeSorter.Add(DocumentTypeFields.Identifier | SortOperator.Ascending);
ISortExpression FileVersionSorter = new SortExpression();
FileVersionSorter.Add(ProjectFileVersionFields.FileVersion | SortOperator.Descending);
IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.ProjectFileEntity);
prefetchPath.Add(ProjectFileEntity.PrefetchPathDocumentType, 0, null, null, DocumentTypeSorter).SubPath.Add(DocumentTypeEntity.PrefetchPathDocumentCategory, 0, null, null, DocumentCategorySorter);
prefetchPath.Add(ProjectFileEntity.PrefetchPathProjectFileVersion, 0, null, null, FileVersionSorter);
IPredicateExpression filter = new PredicateExpression();
filter.Add(ProjectFileFields.ProjectId == ProjectID);
ProjectFiles.GetMulti(filter, prefetchPath);
return ProjectFiles;
The Version sorting goes well, except the DocumentType sort doesnt work?
Right now values like:
-A01
-A03
-A02
Am I missing something?
Best Regards,
Martin