0

我希望 LINQ 准确地生成这个 URI:

http://<webservice>/MULTI_POINT_PARAMParameters(xcenter=1M,ycenter=1M)/Results 

Wherexcenterycenter指定我的密钥,并且Results是包含我想要的数据的 OData 服务的导航属性。如果我在浏览器中输入这个 URI,我会得到我想要的结果。

几乎可以让 LINQ 生成它,但我不能让它最终完成 /Results 部分。所以如果我这样做:

var query = context.MULTI_POINT_PARAMParameters
                   .Where(t => (t.xcenter == 1 && t.ycenter == 1))
                   .Select(t => t);   

我得到这样的URI:

http://<webservice>/MULTI_POINT_PARAMParameters(xcenter=1M,ycenter=1M)

这是一个开始,现在我只需要指定导航参数。我确实试过这个:

var query2 = context2.MULTI_POINT_PARAMParameters
                   .Where(t => (t.xcenter == 1 && t.ycenter == 1))
                   .Select(t => new { t.Results });  

但是,它生成的 URI 如下所示:

http://<webservice>/MULTI_POINT_PARAMParameters(xcenter=1M,ycenter=1M)?$expand=Results&$select=Results

我已经读到上面的 URI 应该是相同的,/Results但是对于我正在处理的特定服务它不起作用,我需要我生成的 URI 与我在开头写的完全一样/Results

有谁知道我怎样才能让 LINQ 做到这一点?

4

1 回答 1

0

试试看SelectMany_

var query2 = context2.MULTI_POINT_PARAMParameters
               .Where(t => (t.xcenter == 1 && t.ycenter == 1))
               .SelectMany(t => t.Results);  

用于SelectMany集合导航属性和Select单个导航属性。

于 2013-08-08T19:27:09.807 回答