I want to use deferred execution to my advantage for updating changing data in a data grid view when the view is filtered. Currently I have an array of rows which can be filtered and the filtered data can then be searched. I use linq queries to filter the data and search the data. I've summarized how I do this below.
IEnumerable<SomeDataRowType> m_mainData =
(select from someDataContext
new SomeDataRowType {
properties...
}).ToArray();
IEnumerable<SomeDataRowType> m_filteredData =
m_mainData.Where(r => r.SomeProperty == someValue);
IEnumerable<SomeDataRowType> m_searchedData =
m_filteredData.Where(r => r.SomeProperty.Contains(someSearchTerm));
myDataGridView.DataSource = new SortableBindingList<SomeDataRowType>(m_searchedData.ToArray());
Now this works great if the m_mainData
data set doesn't change. I can clear the search query and drop back to the filter query, or drop them both, or just apply the search query. Unfortunately if the m_mainData
set DOES change then m_filteredData
and m_searchedData
filter execute on the old m_mainData
data set instead of the new updated one. I sort of understand why this is, but I don't know what my options are to work around this.
I apologize if any of this is unclear. Thanks for the help!