Reputation: 213
I was wondering if it was possible to return a generic type with mvc web api.
eg can I retrun List<T> and NOT List<int> or is this too crazy?
// adding a little more context
// Controller
IRepoClassInterface repo = new ReopClassWorker();
public List<T> Get<T>(string date, string chartName)
{
switch(chartName)
{
case "myCoolChartBrah":
return repo.Get<MyListType>(date);
case "anotherChart":
return repo.Get<AnotherListType>(date);
}
}
Upvotes: 0
Views: 1003
Reputation: 9319
ASP.NET MVC Web API designed to that especially with IQueryable with OData queries. Just give it a try and see.
Upvotes: 1