In the below code how to set generic 'T' as a class dynamically?
Currently am redirecting all the API request to a single web api called "dummy" by routing.
So url's like
"api/person" then take person as class
"api/students" then take students as class
So here how to pass person or students or any other dynamic class in GenericDataController T.
//web api controller
public class dummyController :GenericDataController<T>
{
//
}
GenericData web api
public class GenericDataController<T> :ApiController where T : class
{
private IGenericDataService _dataService;
public GenericDataController(IGenericDataService dataService)
{
_dataService = dataService;
}
// GET: api/GenericData
public IEnumerable<T> Get()
{
return _dataService.Get<T>();
}
}
In my model i have all class models
public class Person{
//
}
public class Student{
//
}