gustavnavar / Grid.Blazor

Grid component with CRUD for Blazor (client-side and server-side) and ASP.NET Core MVC
GNU Lesser General Public License v2.1
700 stars 135 forks source link

GridCoreServer taking an IQueryable #352

Closed ArneMancofi closed 1 year ago

ArneMancofi commented 2 years ago

Is your feature request related to a problem? Please describe. My backend storage provides me with an IQueryable<T>, but GridCoreServer<T> requires an IEnumerable<T>. Given a huge amount of items in storage, I do not want to enumerate them all at once.

Describe the solution you'd like A GridCoreServer<T> that takes an IQueryable<T>.

Describe alternatives you've considered Implementing my own private IGridServer<T>. However, this seems to be a feature generally useful for other projects as well.

gustavnavar commented 2 years ago

You can use IQueryable<T> as GridCoreServer<T`> parameter, because IQueryable<T> has inheritance of IEnumerable<T>.

If the number of records is high, I would use pagination:

    IGridServer<Order> server = new GridCoreServer<Order>(repository.GetAll(), Request.Query,
                true, "ordersGrid", ColumnCollections.OrderColumns)
                    .WithPaging(10);