WCF Web api 和带有 odata 的复杂类型
我正在使用 WCF Web api 来 bui;da 休息服务,该服务从 odata 查询返回复杂对象。不幸的是,查询复杂类型似乎不起作用。 EG
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,其实支持查询复杂类型?如果是这样,我必须做一些特殊的事情才能启用它吗?
I'm using WCF web api to bui;d a rest service that returns coplex objects from an odata query. Unfortunately, querying complex types doesn't seem to work. E.G.
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();
}
The following uri returns nothing.
http://localhost/api/people?$filter=Department/Id%20eq%20'2'
Does the Web Api, in fact, support querying complex types? And if so, is there something special i must to to enable it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已解决:原来我的一些对象具有空描述值。一旦我确定所有的东西都有价值,它就可以正常工作。
Resolved: Turns out some of my objects had null Description values. Once i made sure all had values it worked fine.