IvanJosipovic / BlazorTable

Blazor Table Component with Sorting, Paging and Filtering
https://BlazorTable.netlify.app
MIT License
540 stars 109 forks source link

[Feat] Factory to provide ItemsQueryable #353

Open nadirbongiovanni opened 3 years ago

nadirbongiovanni commented 3 years ago

I'm struggling on managing correctly the EFCore DbContext lifecycle in a project using BlazorTable. If I define as ItemsQueryable parameter on the component a DbSet from the context, as Microsoft guidelines suggest, I dispose it on every request, resulting BlazorTable to thron ObjectDisposedException. The only workaround is keeping the context alive through all the application, which is not adviceable. The idea is to provide another parameter to the component called ItemsQueryableFactory which accepts a Func<IQueryable> which allows the component to be provided a new IQueryable every time it needs and allowing the application using the component to follow the context lifecycle guidelines.