我正在使用 LINQPad 连接到本地 CRM 组织上的 ODATA 服务,但我不知道如何使用 LINQPad 执行“联接”或遍历关系。
这是我的网址
OrganizationData.svc/New_locationSet?$select=new_state_new_location/new_Region$expand=new_state_new_location
在浏览器中运行得很好。这是我在 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 文档极其缺乏......
您只需要投影出您想要扩展的内容,例如:
from p in Products
select new {p.Name, CategoryName = p.Category.Name}
or
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 的请求日志选项卡中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)