如何在LinqPad中执行ODATA扩展

Dar*_*ryl 6 linqpad odata dynamics-crm-2011

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

这是我的网址

OrganizationData.svc/New_locationSet?$select=new_state_new_location/new_Region$expand=new_state_new_location
Run Code Online (Sandbox Code Playgroud)

它在浏览器中工作得很好.这是我在LINQPad中所做的:

from l in new_locationSet
from s in l.new_state_new_location
select s.new_Region
Run Code Online (Sandbox Code Playgroud)

但我收到一个错误:

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'.
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?我发现LINQPad OData文档极其缺乏......

Mar*_*SFT 7

您只需要预测要扩展的内容,例如:

from p in Products
select new {p.Name, CategoryName = p.Category.Name}
Run Code Online (Sandbox Code Playgroud)

要么

Products.Select(p => new { p.Name, CategoryName = p.Category.Name})
Run Code Online (Sandbox Code Playgroud)

会屈服

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

在LinqPad的"请求日志"选项卡中.