Inheriting dbcontext

Hello, this question might not be Radzen specific, but still something I wonder...

I noticed in the demo that dbcontext is defined in DbContextPage.razor and every page inherits from this. I'm still only learning but this doesn't seem to be in line with certain design patterns or layers of abstraction?

Is this for demo purposes? or is this indeed an approach one could use in production?

Not sure what pattern this inheritance breaks. Please explain.

Nearly all documentation or tutorials I checked out all used a layer to abstract dataAccess from the pages. (Repository Pattern I guess)

Not sure how this is related at all. At the end you need to inject either DbContext or DbContextFactory or whatever class is used for data access in your page to access your data. No matter if this is some base page or regular page.

This approach is taken from Microsoft's documentation. Of course it is up to the developer to pick their way of doing DB access - via DBContext, DBFactoryContext, Repository, HTTP service, gRPC, WebSockets or emails :slight_smile:

1 Like