简体   繁体   中英

How can I get GRPC to play nicely with C# POCOs?

So, here's the thing: I am trying to work myself into GRPC for communication between webservices. However, I am not quite sure how I can get C# POCOs to play nicely with GRPC messages.

I downloaded the example provided in the GRPC tutorial here: https://github.com/grpc/grpc and built it in order to be able to inspect what exactly GRPC is generating, and what I end up with is basically a huge chunk of boilerplate GRPC code.

However, I am trying to add GRPC to an existing application, for which I already wrote POCOs which I previously used with WCF, so I am not really looking forward to deleting my existing POCOs in order to exchange them for something I can't really add custom code to and which is kind of only there as long as I will be using GRPC.

So, here is the question - Can I somehow get GRPC and my existing POCOs wired together, or would I have to cast every object after receiving / before sending it?

As of today there's no way to auto generate a gRPC service from existing c# POCOs. There is recent github issue that brings up this use case though https://github.com/grpc/grpc-dotnet/issues/68 .

I imagine it won't be too difficult to introduce some sort of shim layer to translate the auto generated profobuf models to your POCOs?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM