I have this method in my web api:
[HttpGet("GetPerson/{id}")]
[Authorize(Roles = "Administrators")]
public async Task<(Person, List<ContactData>)> GetPerson(int id = 0)
{
Data.ThePerson person = new Data.ThePerson();
List<ContactData> cDatas = person.contactDatas.Where(it => it.ContactId == id).ToList();
var p = person.persons.FirstOrDefault(p => p.Id == id);
return (p, cDatas);
}
But the method returns (, ) in the client! How to correct this?
Client:
public async Task<(Person, List<ContactData>)> GetPerson(int id)
{
var tuple = await Http.GetFromJsonAsync<(Person, List<ContactData>)>($"api/account/GetPerson/{id}");
return tuple;
}
The server and client methods work when it only returns a Person object but converting it to tuple returns (, ). also I can see in the server that correct tuple builds and returns but in the client it is (, ).
GetPerson()service call. Also check other questions like stackoverflow.com/questions/58961133/… and stackoverflow.com/questions/50005989/…Data.ThePerson person = new Data.ThePerson();; the constructor of ThePerson returns an object, which contains a collection "persons", that presumably includes all the persons in the repository? This seems remarkably inefficient, as well as being unnatural nomenclature (a noun in the singular housing a collection of itself in the plural). Why do you not have a constructor that simply takes an id?