I am creating a repository as follows:
public class StagingRepository
{
private IRepository<CurrentTransformer> CurrentTransformerRepository { get; set; }
private IRepository<Equipment> EquipmentRepository { get; set; }
private IRepository<Line> LineRepository { get; set; }
public StagingRepository()
{
this.CurrentTransformerRepository = new Repository<CurrentTransformer>();
this.EquipmentRepository = new Repository<Equipment>();
this.LineRepository = new Repository<Line>();
}
}
All this works... however what I am trying to add is a method within the class that returns one of the Repositories above based on a string value.
public IRepository<Object> SetRepo(string TableName)
{
switch (TableName)
{
case "Line":
return LineRepository;
break;
}
}
I know the above does not work but it gives you an idea of what I am trying to accomplish. My goal would be I should be able to setup something like this in my code to call the repository:
StagingRepository _repo = new StagingRepository();
var myList = _repo.SetRepo("Line").All(); //All is a function of IRepository
Any Help would be greatly appreciated.