0

We have multiple classes/entities and wants to implement single query for all these types. Basically we want to implement a Query something like this.

public class Query<TEntity> 
    {
        private readonly IGenericRepository<TEntity> _genericRepository;

        public Query(IGenericRepository<TEntity> genericRepository)
        {
            _genericRepository = genericRepository;
        }
        public List<TEntity> GetCountries()
        {
            return _genericRepository.GetAll();
        }
    }

Can you please give any hint or reference for the similar problem?

Oxygen
  • 831
  • 4
  • 17
  • 42
  • AFAIK the closest you can do is to provide an enum as input and a union as output. Every time you want to add support for a new `TEntity` you will have to extend the enum and union. – Artur Apr 29 '23 at 08:55

0 Answers0