I’m wondering where the best place to put Type specific functions is when using a generic repository pattern.
My generic Repository<T> has methods for things like GetMany() etc, but where is the most sensible location to place functions specific to a Type?
A simple example would be, say I have a ‘User’ type and I want a function, which instead of bringing back the firstname / lastname of the user and requiring me to glue them together when the object set is returned, could return FirstName + " " + LastName as ‘Username‘.
The previous non repository pattern implementation I’ve inherited used partial classes on the EF types to provide these extension methods, but I’m a little unsure where to move these type of functions to when using the respository.
Any ideas would be a big help,
Cheers,
Doug
The below link explains how to specify selection, instead of widening the contract of generic repository, the common technique is to subclass the generic repository to implement a specific repository
EF POCO
you can add your function as the one used for NewlySubscribed()