Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programatic generation of OData Proxy

Tags:

odata

There is OData Service using WCF Data Services (ADO.NET Data Services) available. I need to consume the OData Service in programmatic way. In the sense I do not want to use DataSvcUtil to create the proxy. Instead at runtime I need to generate the OData Proxy.

For WSDL, it is possible to generate the proxy using CodeDOM and System.ServiceModel.Discovery.

I am curious to know whether there is any programatic way of generating the OData Proxy.

Thanks

like image 679
Venki Avatar asked Nov 25 '25 18:11

Venki


1 Answers

DataSvcUtil uses this class http://msdn.microsoft.com/en-us/library/system.data.services.design.entityclassgenerator_members.aspx to generate the code. So you can do the same. Once you have the source code generated, call a compiler on it (I think CodeDOM can do that as well) and load the result dll. It takes an XmlReader so you will have to create an XmlReader from the $metadata enpoint of your service, but that's pretty straightforward.

like image 197
Vitek Karas MSFT Avatar answered Nov 28 '25 15:11

Vitek Karas MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!