Is it possible? How?
I have an asynchronous method fetching rows of data from my database.
My result is IAsyncEnumerable<TItem>.
It should be a perfect data type for a fast and responsive UI, however - when I set it as a datasource for my grid it just doesn't work and shows nothing.
I have 2 workarounds for this. First is obviously to return array from my async task. The second one is similar - I can just use ToArrayAsync() on result (from System.Linq.Async).
I suspect that using ToArrayAsync() is slower than just returning the array from the task, so it doesn't make much sense.
It would make a lot of sense if IAsyncEnumerable type could be used directly as a data source for the control. But then I probably need to implement some kind of IObservable interface or something like that. Did anyone tried this?
The whole thing is pretty new and I can't find any examples, or even an article stating that it's even possible. I mean - what good IAsyncEnumerable is if you cannot use it for the UI?
Update: what I'm looking for is a conversion between IAsyncEnumerable<TItem> and ObservableCollection<TItem>. I found examples, but they all work exactly as my mentioned workaround - so the data is put into an array and then added to the collection. This defeats all IAsyncEnumerable<T> benefits.