开发者

Reuse existing types with ADO.NET Data Services

开发者 https://www.devze.com 2022-12-18 10:41 出处:网络
I have an application which consumes both a WCF service and an ADO.NET Data Service. Types are shared between the server and client using a shared class library.

I have an application which consumes both a WCF service and an ADO.NET Data Service. Types are shared between the server and client using a shared class library.

When I configure the service reference for the WCF service, I can choose to use the existing types in the class library to avoid creating duplicate types in the proxy classes.

But Visual St开发者_如何学编程udio doesn't offer me the option to do that on the ADO.NET Data Service.

Is it possible for an ADO.NET Data Service to reuse existing types?


Great question.

Yes this is definitely possible.

I just put together a Tip that show you how to turn off default Code-Gen and reference an existing type instead, and showing how too tell the DataServiceCpntext how to do the mapping between the type expected on the wire and the type used on the client.

NOTE: that even though the Types might be the same inside the DataService and on the client it is still possible that the Data Service has been configured to expose the Server types in a different namespace, so this mapping may still be required.

Anyway I'm sure Tip 52 will help you get your scenario working.

Alex


Way i would do is instead of creating proxy through add service option. Use DataServiceContext directly then can use

Execute<TypeOfData> method
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号