DEV Community


Using C# Tuples in EF Core Repositories

cesarcodes profile image Cesar Codes ・1 min read

I recently started using Tuples in my repositories as a way to achieve self-documenting code. For example, let’s say that you have a simple application that returns only 2 entities in 1 call. You could write 2 methods on your repository and then call them both from your service layer, as is common. However, I think in such situations you’d be better served combining the entity calls in the repo and receiving them in your service layer so that looking at the code base, it’s clear that certain entities are only needed for certain operations. It can also help make your repositories more lean in certain situations.

Thanks for reading, if you read up to this, consider getting yourself a Hardcore .NET Core Developer Sticker Pack:


Discussion (0)

Editor guide