Reputation: 129
i have a large collection in a sql database. when i use DataSet
, i'm assuming i'm pulling all (and when I say all, i mean 20000+) database entries at once to populate a scrollable WPF list view. when i pull that much data, and more data is added, i'm running out of memory.
i asked a similar question here:program using up all memory from listview sql table, how to populate with only the relevant data? and i need to use it with a list view.
how do i only pull the data i need when the user scrolls? would DataRead
work here? i've seen tutorials on DataRead, but they're usually button based, and i need to dynamically read the data based on which direction the user scrolls in the list view.
is there a way to make it update based on, say 30, values, if the user sees 15 of them, then the lag between the server query and returned value wouldn't cause the list view to have any problems as the user scrolls up or down?
Upvotes: 3
Views: 1711
Reputation: 31454
i'm assuming i'm pulling all (and when I say all, i mean 20000+) database entries at once to populate a scrollable WPF list view
Why? Can you imagine anyone analyzing 20000+ elements at once? Do you expect your users to look at 20000+ elements at once? You should have a very good reason to pull entire data set at once. "To display for users" is rarely such reason.
Those kind of problems are usually dealt with in either of two ways:
ListView
ItemContainer
(from VirtualizingStackPanel
to something else) or manually disabled virtualization, it should work fine.On the SQL side, you want to have queries with limit and offset to decide at runtime which part of data set should be fetched.
Upvotes: 1