小编Jan*_*sen的帖子

ASP.NET Web API IQueryable <T>挑战

我想在我的控制器中使用以下模式:

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)

可以这样做吗?
推荐的方法是什么?

asp.net-web-api

4
推荐指数
1
解决办法
3380
查看次数

标签 统计

asp.net-web-api ×1