我希望在我的控制器中使用以下模式:
api/{控制器}/{ID}/{集合}
例如: api/customers/123/addresses
但是我想从相应的Get操作返回IQueryable Of T
。 我想要类似于以下内容(简化):
public IQueryable<????> GetCollection(int id, string collection)
{
switch(collection)
{
case "addresses":
return _addresses.AsQueryable();
break;
case "orders":
return _orders.AsQueryable();
break;
default:
throw new Exception(NotSupported);
}
}
这可以做到吗?
推荐采用什么方法?