Calling an OData Service Operation from Linqpad
Asked Answered
E

1

5

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!

Electroanalysis answered 20/4, 2011 at 20:26 Comment(0)
U
7

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'")
Ushas answered 21/4, 2011 at 0:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.