I have a problem with saving data from firebase in string. While i try to display data i saved from list to string i get the
System Collection Generic List with model instead of the string data
Getting the data from firebase:
public async Task<List<StudentModel>>GetAll()
{
return (await firebaseClient.Child(nameof(StudentModel)).OrderByKey().LimitToLast(1).OnceAsync<StudentModel>()).Select(item => new StudentModel
{
Id = item.Key
}).ToList();
}
Convert and display
var students = await studentRepo.GetAll();
string key = students.ToString();
await DisplayAlert("a", key, "a");
I dont understand why it happens, also if someone knows an easier way to do it i would love to hear it. Thanks
CodePudding user response:
studentRepo.GetAll
returns a List<StudentModel>
. You are trying to turn that in a single string. Either update your query to return a string, or you can extract just the key value using students[0].Id