How to perform ODATA extension in LinqPad

I use LINQPad to connect to ODATA services in a local CRM organization, and I don’t know how to make “connections” or work around relationships using LINQPad.

Here is my url

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

which works fine in the browser. Here is what I do in LINQPad:

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

but I get an error:

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'.

Any ideas? I found that the LINQPad OData documentation is missing ...

+5
source share
1 answer

You just need to design what you want to expand, for example:

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

or

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

will give

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

on the LinqPad query log tab.

+7
source

All Articles