具有相同名称的密钥上的OData Webapi v6.0.0 $ orderBy失败

时间:2017-01-27 18:57:26

标签: c# asp.net asp.net-web-api odata asp.net-web-api-odata

我有OData Webapi控制器,型号如下: (所有代码也可在此github仓库中找到:https://github.com/Malyngo/ODataWebapiTest

@IBOutlet weak var scrollView: UIScrollView!

override func viewDidLoad() {
    super.viewDidLoad()

    let storyboard = UIStoryboard(name: "Main", bundle: nil)

    let aVC = storyboard.instantiateViewController(withIdentifier: "A") as! aVC
    let bVC = storyboard.instantiateViewController(withIdentifier: "B") as! bVC;
    let cVC = storyboard.instantiateViewController(withIdentifier: "C") as! cVC;


    let bounds = UIScreen.main.bounds
    let width = bounds.size.width
    let height = bounds.size.height;

    scrollView!.contentSize = CGSize(width: 3*width, height: height);

    let viewControllers = [aVC, bVC, cVC]

    var idx:Int = 0;

    for viewController in viewControllers {
        addChildViewController(viewController);
        let originX:CGFloat = CGFloat(idx) * width;
        viewController.view.frame = CGRect(x: originX, y: 0, width: width, height: height);
        scrollView!.addSubview(viewController.view)
        viewController.didMove(toParentViewController: self)
        idx += 1;
    }
    view.addSubview((scrollView?.superview)!)
}

控制器设置非常标准,获取客户的方法如下:

public class Customer
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int AddressId { get; set; }
    public Address Address { get; set; }
    public int WorkAddressId { get; set; }
    public Address WorkAddress { get; set; }
    public Customer Parent { get; set; }
    public IList<Customer> Children { get; set; }
}

public class Address
{
    public int Id { get; set; }
    public string Name { get; set; }

    public IList<Customer> Customers { get; set; }
}

当我提出以下请求时: http://localhost:60272/odata/Customers?$排序依据=名称 它没有问题。

但如果我这样做: http://localhost:60272/odata/Customers?$的OrderBy =地址/名称,招聘人数/名称

我收到错误消息:

  

URI中指定的查询无效。 '$ orderby'

不支持名为'Name'的重复属性

根据OData(https://github.com/OData/WebApi/issues/630)的github页面,这是一个应该在我正在使用的v6.0.0中修复的错误,但我仍然看到这个问题。

我做错了吗? 我在这里的github repo中有我的代码: https://github.com/Malyngo/ODataWebapiTest

0 个答案:

没有答案