我想在我的控制器中使用以下模式:
API/{控制器}/{ID}/{收集}
示例: api/customers/123/addresses
但我想IQueryable Of T从相应的Get动作返回.我想要这样的东西(简化):
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);
}
}
Run Code Online (Sandbox Code Playgroud)
可以这样做吗?
推荐的方法是什么?