简体   繁体   English

如何让GRPC与C#POCO很好地配合?

[英]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. 所以,这就是事情:我正努力让自己进入GRPC,以便在webservices之间进行通信。 However, I am not quite sure how I can get C# POCOs to play nicely with GRPC messages. 但是,我不太确定如何让C#POCO与GRPC消息很好地配合。

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. 我在这里下载了GRPC教程中提供的示例: https//github.com/grpc/grpc并构建它以便能够检查GRPC正在生成什么,以及我最终得到的基本上是一大块样板GRPC代码。

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. 但是,我正在尝试将GRPC添加到现有的应用程序中,为此我已经编写了我以前与WCF一起使用的POCO,所以我真的不期待删除我现有的POCO以便将它们换成我不能真正的东西只要我将使用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? 所以,这里有一个问题 - 我可以以某种方式将GRPC和我现有的POCO连接在一起,或者我必须在收到/发送之前投射每个对象吗?

As of today there's no way to auto generate a gRPC service from existing c# POCOs. 截至今天,无法从现有的c#POCO自动生成gRPC服务。 There is recent github issue that brings up this use case though https://github.com/grpc/grpc-dotnet/issues/68 . 最近github问题通过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? 我想,引入某种垫片层将自动生成的profobuf模型转换为您的POCO并不会太困难?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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