Search code examples
c#.net-corerealmmauiwinui

Does Realm-dotnet ordered query fetch all collection data, when bound to a virtualized list control?


Consider this Realm query

IQueryable<Cat> OrderedCats = _localRealm.All<Cat>().OrderBy(c => c.Position);

If I bind a virtualized list view's ItemsSource to OrderedCats, will I still have the benefit of lazy loading (reducing memory footprint), or will OrderBy force loading of all the cats collection, for sorting?

I've never been out of memory, and my use case will barely exceed a few thousands rows, but I'm really curious about Realm database possibilities in desktop apps with large database.


Solution

  • You still get the benefits of lazy-loading. The query, including the sort clause, will be executed by the database and the entities won't be materialized.