EDMIService: Property Filtering/Sorting, Handle Empty Results

This commit is contained in:
Jonathan Jenne
2020-12-08 16:42:36 +01:00
parent 4c9abf3b1f
commit 502793aed5
7 changed files with 116 additions and 33 deletions

View File

@@ -82,9 +82,18 @@ Public Class EDMIService
' Apply filter and sorting to data
Dim oFilterExpression As String = Utils.NotNull(FilterExpression, String.Empty)
Dim oSortByColumn As String = Utils.NotNull(SortByColumn, String.Empty)
Dim oFilteredTable = oDataTable.
Select(oFilterExpression, oSortByColumn).
CopyToDataTable()
Dim oFilteredRows = oDataTable.Select(oFilterExpression, oSortByColumn)
Dim oFilteredTable As DataTable = Nothing
If oFilteredRows.Count > 0 Then
oFilteredTable = oFilteredRows.CopyToDataTable()
oFilteredTable.TableName = Name
Else
' Produce empty table
oFilteredTable = oDataTable.Clone()
oFilteredTable.TableName = Name
End If
_logger.Debug("Datatable Stats for [{0}]:", Name)
_logger.Debug("Unfiltered: [{0}] rows", oDataTable.Rows.Count)
@@ -94,14 +103,6 @@ Public Class EDMIService
Else
Throw New ApplicationException($"DataTable {Name} does not exist")
End If
'If oDataset.Tables.Contains(Name) Then
' oDataTable = oDataset.Tables.Item(Name).Clone()
' Return New TableResult(oDataTable)
'Else
' Throw New ApplicationException($"DataTable {Name} does not exist")
'End If
Catch ex As Exception
_logger.Error(ex)
Return New TableResult(ex.Message)