Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling an OData Service Operation from Linqpad

Does anyone know if its possible and if so, what the syntax is for calling a service operation via linqpad?

Also, can I used named parameters when I call it using linqpad- how? That would be great b/c I have a lot of parameters in the service operation and I don't want to have to specify each one.

Thanks!

like image 880
skeej Avatar asked Apr 20 '11 20:04

skeej


1 Answers

Unfortunately, this is not possible: LINQPad relies on the .NET WCF client and EntityClassGenerator in System.Data.Services.Design.dll, which don't really support service operations (as of Framework 4.0).

The workaround at this stage is the same as what you'd do if you were coding in Visual Studio and is described well here.

Hence you could type the following into LINQPad to call the operation GetContacts(string firstName):

this.Execute<Contact> (new Uri ("GetContacts?firstName='John'", UriKind.Relative))

or, if the service returns a sequence of objects:

CreateQuery<Contact>("GetContacts").AddQueryOption("firstName", "'John'")
like image 139
Joe Albahari Avatar answered Sep 30 '22 02:09

Joe Albahari