C#C
C#3y ago
daysleeper

Generic access to DbContext implementation

Okay, so I wanted to do the generic repository for my project and my searches in google didn't give me satisfying answers so I tried to do something myself. My question is whether my attempt is right or wrong and why? (.NET 6, EF 6)

My entities all inherit from Entity class.
So first thing that bothers me is thread safety, is it thread safe, am I using DbContext.Set() method right? Also the optimization part, would invoking Set() for every Repository like I did be much resource heavier?
image.png
image.png
image.png
image.png
image.png
image.png
Was this page helpful?