C
C#2y ago
Krai

❔ Code review

What do you think about this usage at generic repository?
10 Replies
ero
ero2y ago
I think you shouldn't ignore your warnings
cathei
cathei2y ago
I think it is fine other than warning, but could get tedious when you need more than Where.
atamakit
atamakit2y ago
It is difficult for me to provide a detailed opinion on the specific usage of the generic method without more context about the purpose of the method and the specific requirements of the project. In general, using a generic method can be a useful way to write reusable code that can be applied to different types of entities. It can make code easier to maintain and update, and can make it easier to read and understand. However, it is also important to carefully consider the trade-offs of using a generic method, such as the potential impact on performance and testing, as well as the level of type safety in the code. Ultimately, the decision of whether to use a generic method or not should be based on a careful evaluation of the specific needs and constraints of the project, as well as a broader design of the codebase. I hope this helps.
sibber
sibber2y ago
did you copy this from chatGPT?
atamakit
atamakit2y ago
yes i did
sibber
sibber2y ago
chatgpt doesnt know conventions or good pratices. it just generates a response based on what it was trained on. which means it can be very wrong without seeming like it tldr: dont ask chatgpt about things like this
Angius
Angius2y ago
I think "don't use generic repositories over EF" If someone's holding you at gunpoint, though, I'd say it looks good enough Although I'd probably use an overloaded method instead One-liner methods that are essentially
public T GetAll<T>(x) => ctx.GetAll<T>(x);
public T GetAll<T>(x) => ctx.GetAll<T>(x);
have the added benefit of showing how pointless they are
Krai
KraiOP2y ago
Thank you everyone Do you suggest create extensions for efcore? or for entities
Angius
Angius2y ago
Yeah, IQueryable extensions are fine I have plenty of them, like .Paginate() or .FilterBlocked()
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server