【问题标题】:WCF Web api and complex types with odataWCF Web api 和带有 odata 的复杂类型
【发布时间】:2012-02-02 23:40:56
【问题描述】:

我正在使用 WCF Web api 构建一个从 odata 查询返回复杂对象的休息服务。不幸的是,查询复杂类型似乎不起作用。例如

 public IQueryable<Person> Get()
    {
        var people = new List<Person>()
        {
            new Person {
                Name="John", 
                Department = new Department{Id=2, Description="Lion Swaddling"}
            },
            new Person {
                Name="Jane", 
                Department = new Department{Id=4, Description="Face Surgery"}
            },
        };

        return people.AsQueryable();
    }

以下 uri 不返回任何内容。 http://localhost/api/people?$filter=部门/Id%20eq%20'2'

Web Api 实际上是否支持查询复杂类型?如果是这样,我必须要启用它吗?

【问题讨论】:

    标签: wcf wcf-data-services odata wcf-web-api


    【解决方案1】:

    已解决:原来我的一些对象的描述值为空。一旦我确定所有的值都可以正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-08
      • 2015-01-03
      • 1970-01-01
      • 1970-01-01
      • 2013-05-26
      • 2012-10-05
      相关资源
      最近更新 更多