Dil*_* AT 4 .net c# grpc asp.net-core
我在 .NET core 7.0 上工作
syntax = "proto3";
option csharp_namespace = "IndustryAPI.Protos";
message ListOfStrings {
repeated string strings = 1;
}
enum VendorMode {
VendorMode_UNSPECIFIED = 0;
Shopping = 1;
Discovery = 2;
ShoppingAndDiscovery = 3;
}
message VendorModel {
string Id = 1;
string Name = 2;
string Channel = 3;
string Address = 4;
string ContactNummber = 5;
string Email = 6;
string Web = 7;
}
service VendorService {
rpc GetVendorBasicDetails(GetVendorBasicDetailsRequest) returns (GetVendorBasicDetailsResponse);
}
// requests
message GetVendorBasicDetailsRequest {
string channelId = 1;
string VendorCreatedDateStart = 2;
string VendorCreatedDateEnd = 3;
}
message GetVendorBasicDetailsResponse {
repeated VendorModel Vendor = 1;
}
Run Code Online (Sandbox Code Playgroud)
这是vendor.proto文件。
在此模型中,web 字段可为空值。
所以,这就是返回错误。
处理程序抛出异常。ArgumentNullException:值不能为空
如何定义可为空字段?
我找到了解决方案。
如果我们设置一个可为空的字段,请使用Google的Wrapper.proto文件:
import "google/protobuf/wrappers.proto";
message MyMessage {
google.protobuf.StringValue web = 7;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1329 次 |
| 最近记录: |