I have a performance bottleneck on a DataView.Sort. The code is below.
/// <summary>
/// Filters the data table and returns a new data table with only the filtered rows.
/// </summary>
/// <param name="dtInput">The dt input.</param>
/// <param name="filterExpression">The filter expression.</param>
/// <returns></returns>
protected virtual DataTable FilterDataTable(DataTable dtInput, string filterExpression)
{
DataTable result = dtInput;
if (!string.IsNullOrEmpty(filterExpression) && filterExpression.Trim().Length > 0)
{
DataView view = new DataView(dtInput);
view.RowFilter = filterExpression;
view.Sort = HierarchyFieldMap.DisplayedValue;
result = view.ToTable();
}
return result;
}
Any idea's on how to improve this method?
It takes ~1 second to execute.
EDIT
I found this link on DataView's Poor Peformance with Large RecordSets