如何在LinqPad中执行ODATA扩展 [英] How to perform an ODATA expand in LinqPad

查看:172
本文介绍了如何在LinqPad中执行ODATA扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用LINQPad连接到本地CRM组织上的ODATA服务,但我不知道如何使用LINQPad执行联接"或遍历关系.

I'm using LINQPad to connect to the ODATA services on a local CRM organization and I don't know how to perform "joins" or to traverse relationships using LINQPad.

这是我的网址

OrganizationData.svc/New_locationSet?$select=new_state_new_location/new_Region$expand=new_state_new_location

在浏览器中可以正常工作.这是我在LINQPad中所做的事情:

which works just fine in the browser. Here is what I'm doing in LINQPad:

from l in new_locationSet
from s in l.new_state_new_location
select s.new_Region

但是我遇到了错误:

An expression of type 'LINQPad.User.New_state' is not allowed in a subsequent from clause in a query expression with source type 'System.Data.Services.Client.DataServiceQuery<LINQPad.User.New_location>'.  Type inference failed in the call to 'SelectMany'.

有什么想法吗?我发现LINQPad OData文档极度缺乏...

Any ideas? I've found the LINQPad OData documentation extremely lacking...

推荐答案

您只需要计划要扩展的内容,例如:

You just need to project out what you want to expand, e.g.:

from p in Products
select new {p.Name, CategoryName = p.Category.Name}

Products.Select(p => new { p.Name, CategoryName = p.Category.Name})

将产生

http://services.odata.org/(S(readwrite))/OData/OData.svc/Products()?$expand=Category&$select=Name,Category/Name

在LinqPad的请求日志"标签中.

in LinqPad's Request Log tab.

这篇关于如何在LinqPad中执行ODATA扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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