tags:

views:

54

answers:

1

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

A: 

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.

Vitek Karas MSFT