Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier creation of LoadFromQueryableAsync extension method #688

Merged
merged 1 commit into from
May 3, 2019

Conversation

tomasherceg
Copy link
Member

We'll need to wait until .NET Core 3.0 is released to be able to make LoadFromQueryableAsync method (as explained in #670) since ToListAsync and CountAsync are declared in EF Core assemblies and we didn't want DotVVM to depend on that.

However, to allow users making their own implementation of LoadFromQueryableAsync as an extension method, I have changed several methods on GridViewDataSet to be public.

Making an extension method for LoadFromQueryableAsync can now be done like this:

        public static async Task LoadFromQueryableAsync(this GridViewDataSet<T> dataSet, IQueryable<T> source)
        {
            source = dataSet.ApplyFilteringToQueryable(source);
            dataSet.Items = await dataSet.ApplyOptionsToQueryable(source).ToListAsync();
            dataSet.PagingOptions.TotalItemsCount = await source.CountAsync();
            dataSet.IsRefreshRequired = false;
        }

This also fixed one inconsistency we had on GridViewDataSet - all Apply*ToQueryable except for ApplySortingToQueryable were protected while ApplySortingToQueryable was already public. Now they are all public.

Copy link
Member

@exyi exyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this makes sense.

@tomasherceg tomasherceg merged commit 9765343 into master May 3, 2019
@quigamdev quigamdev deleted the feature/load-from-queryable-async branch September 18, 2019 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants