查询OData api:过滤到amany到很多关系 [英] Query an OData api: filter within a amany to many relationship

查看:131
本文介绍了查询OData api:过滤到amany到很多关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我有一个包含2个桌子的数据库:

- 招聘人员

- 地址



这些表格有:m关系。



我通过OData api连接数据库。



我正在尝试获取特定招聘人员的地址,但无法让它工作。



我试过的是:

Hello,

I have a database containing 2 tables:
- recruiters
- Addresses

These tables have a n:m relationship.

I connect with the database through an OData api.

I'm trying to get the addresses of a specific recruiter but can't get it to work.

What I've tried is:

var addressesQuery = from a in _container.Addresses.Expand(a => a.Recruiters.Where(p => p.ID =- recruiter_ID))
select a





这给出了System.NotSupported异常。

具体:

表达式a => a.Persons。其中(p =>(p.ID == xxxxxx))不是导航路径的有效表达式。 lambda表达式主体内部支持的操作是MeberAccess和TypeAs。

表达式必须包含至少一个MeberAccess并且它不能以TypesAs结尾



我尝试了很多变种,但总是得到错误。



任何提示或想法?



Jeroen



This gives a System.NotSupported exception.
Specific:
"The expression a => a.Persons. Where( p => (p.ID == xxxxxx)) is not a valid expression for navigation path. The only supported operations inside the lambda expression body are MeberAccess and TypeAs.
The expression must contain at least one MeberAccess and it cannot end with TypesAs"

I've tried many variants but always get the error.

Anyone tips or ideas?

Jeroen

推荐答案

我在遇到此链接后想出来了 http://stackoverflow.com/questions/2247051/how-to-use-selectmany-with-dataservicequery [<一个href =http://stackoverflow.com/questions/2247051/how-to-use-selectmany-with-dataservicequerytarget =_ blanktitle =New Window> ^ ]



我首先通过查询和过滤招聘人员以及地址来解决查询问题。



查询结果如下:



I figured it out after I came across this link http://stackoverflow.com/questions/2247051/how-to-use-selectmany-with-dataservicequery[^]

I turned the query around by first querying and filtering the recruiters and then the addresses.

The query ended up like this:

var addressesQuerry = from r in _container.Recruiters
.Where(r => r.ID == recruiter_ID)
from a in r.Addresses
select a;





跟我一起思考。



Thnaks for thinking with me.


这篇关于查询OData api:过滤到amany到很多关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆