So, I am having a hard time with this Repository pattern. In lots of articles, posts and etc. I read that the repository should return only database objects(no DTOs, no mappers inside the repository).So you return single database object or list of objects.
This is OK, but for EF(entity framework) performance reasons, it's OK to return only field's that you need, not the entire entity.
So, how are you supposed to do that with repository pattern? You cannot select the database object with specific fields because it is detached
(ctx.Users.Select(new User(){ properties }).FirstOrDefault())
, you cannot return an anonymous object, and as I read it's not good practice to return IQueryable<User> and outside the repository to select desired fields.
Can you share some practice?