We have a jtable which have some columns whose value is calculated based on some conditions.
var documents = await documentsQuery
.Select(x => new DocumentListDto
Id = x.Id,
Title = x.Title,
File_Size_Presenter = x.File_Size + " KB",
Document_Approval_Type = x.Entity_Document_Approval_Types.Approval_Type,
Document_Approval_Type_ID_FK = x.Document_Approval_Type_ID_FK,
CreationTime = x.CreationTime,
Approvers = x.Entity_Approvers.Count(),
Status = x.Is_Publish ? "Published" : "Pending",
Status2 = x.Is_Publish ? "Document has been published" : "Pending Approval"
Author = x.AbpUser_OriginalWriterUser.Name + " " + x.AbpUser_OriginalWriterUser.Surname,
DocumentAdmin = x.AbpUser_DocumentAdminUser.Name + " " + x.AbpUser_DocumentAdminUser.Surname
Here, columns like Status, Status2, Author, DocumentAdmin does not exists in database.
Applying filter on them would mean to first fetch all data and then filter it, which does not seem like any efficient way.
We are also using paging and sorting and we cannot lose this functionality. (Sorting is not working on calculated columns. So, as a bonus, if you have a solution to that, it'll be much appretiated )
I believe many of you, like me, would have banged your head on wall to do this correctly.
So, how could this be handled in an elegant way?