2012-01-05 112 views
1

我使用WCF web api來構建; d是從odata查詢返回coplex對象的其他服務。不幸的是,查詢複雜類型似乎不起作用。例如。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 = Department/Id%20eq%20'2'

Web Api實際上是否支持查詢複雜類型?如果是這樣,有什麼特別的我必須啓用它?

回答

1

解決:發現我的一些對象具有空值描述值。一旦我確定所有的值都可以正常工作。