I have got below three methods and they are returning same return type and the only difference among these three methods is that the data is getting retrieved from different tables.
Below are those methods.
public IQueryable<SpaceFunctionType> GetSpaceFunctionForA170(string airFlowSource)
{
return _dbContext.A170.Where(s => s.AirflowSourceName == airFlowSource)
.Select(c => new SpaceFunctionType
{
Category = c.Category,
SpaceFunction = c.SpaceFunction
});
}
public IQueryable<SpaceFunctionType> GetSpaceFunctionForA621(string airFlowSource)
{
return _dbContext.A621.Where(s => s.AirflowSourceName == airFlowSource)
.Select(c => new SpaceFunctionType
{
Category = c.Category,
SpaceFunction = c.SpaceFunction
});
}
public IQueryable<SpaceFunctionType> GetSpaceFunctionForEquipment(string airFlowSource)
{
return _dbContext.Equipments.Where(s => s.EquipmentSourceName == airFlowSource)
.Select(c => new SpaceFunctionType
{
Category = c.Category,
SpaceFunction = c.SpaceFunction
});
}
Could any one please help me suggest any ideas on this how to combine these methods in a generic way. I am using Entity Framework Core.