dotnet / dotnet/wpf

Performance delay when filtering a DataTable using the DefaultView.RowFilter property

Open
#9,503 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

When filtering the DataTable using the DefaultView.RowFilter property, it takes a long time (more than 2 minutes) to apply the filter. The number of items being filtered is 5,800. Please find the code snippet below.

**Note: The filter string was provided along with the sample.**

**C# code:**

```
private void FilteringButton_Click(object sender, RoutedEventArgs e)
{
DataTable dataTable = getDataReturn();
var filterString = File.ReadAllText(@"..\..\Filterstring.txt");
dataTable.DefaultView.RowFilter = filterString;
}

```

**Output reference:**

https://github.com/user-attachments/assets/d4e746c9-d665-4c53-b3c0-76f6167296f9

**Sample:**

[DataTable_Filtering_Demo.zip](https://github.com/user-attachments/files/16459846/DataTable_Filtering_Demo.zip)

### Reproduction Steps

1. Run the sample
2. Click the "Click to filter" button to filter

### Expected behavior

The filter should not take too much time.

### Actual behavior

The filtering takes too much time.

### Regression?

_No response_

### Known Workarounds

_No response_

### Impact

_No response_

### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.