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
1条答案
按热度按时间juud5qan1#
studentRepo.GetAll
返回**List<StudentModel>
**。您正试图将其转换为单个字符串。请更新查询以返回字符串,或者使用students[0].Id
只提取键值