我有一个函数调用 gRPC 端点,将对象转换为 POCO 对象并将它们作为列表返回。
public class ActionPlanConnectionsService : IConnectionService
{
#region Fields
/// <summary>
/// Grpc client
/// </summary>
private readonly ConnectionDb.ConnectionDbClient _client;
#endregion
public ActionPlanConnectionsService(ConnectionDb.ConnectionDbClient channel)
{
_client = channel;
}
public async Task<IEnumerable<Connection>> Get(int actionPlanId, int implementation)
{
List<Connection> diagramConnections = new List<Connection>();
GetConnectionsByIdAndImplementationMessage message = new GetConnectionsByIdAndImplementationMessage
{
ActionPlanId = actionPlanId,
Implementation = implementation
};
using var call = _client.GetAllConnections(message);
await foreach (ConnectionServiceModel connection in call.ResponseStream.ReadAllAsync())
{
// Never enters here as ResponseStream has no elements …Run Code Online (Sandbox Code Playgroud)