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 pr开发者_开发百科ogramatic way of generating the OData Proxy.
Thanks
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.
精彩评论