I want to get an object with a list. A people and db result for this.
To describe the problem I share the proto file, and then the code c # where when copy and pasting visual studio marks the errors.
A profo file is:
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.example.migrpc.javierpersonas";
option java_outer_classname = "JavierPersonas";
option objc_class_prefix = "HLW";
package javierpersonas;
service ServicioProbarPersonas {
rpc ListaPersonas(PersonaCompleto) returns (stream PersonaCompletoCollection) {}
}
message PersonaCompleto {
int32 idpersona = 1;
string nombre = 2;
string apellido = 3;
int32 edad = 4;
bool active = 5;
string status =6;
}
message PersonaCompletoCollection {
repeated PersonaCompleto personasCompleto = 1;
bool title = 2;
string titlename =3;
}
The file c# is
public override async Task<PersonaCompletoCollection> L istaPersonas(PersonaCompleto request, IServerStreamWriter<PersonaCompletoCollection> responseStream, ServerCallContext context)
{
List<PersonaCompleto> listaPersonas = new List<PersonaCompleto>();
var itemsDb = await _context.Persona.ToListAsync();
foreach (var item in itemsDb)
{
var people = new PersonaCompleto();
people.Idpersona = item.idpersona;
people.Apellido = item.apellido;
people.Nombre = item.nombre;
people.Edad = item.edad;
listaPersonas.Add(people);
}
PersonaCompletoCollection res = new PersonaCompletoCollection();
res.Title = true;
res.Titlename = "doctor";
res.PersonasCompleto = listaPersonas;
await responseStream.WriteAsync(res);
return await Task.FromResult(res);
}
Res.Personacompleto is read only. What do you recommend? You can share a code?