Hello,
Welcome to our Microsoft Q&A platform!
Firstly, I add the breakpoint in the ReadAsync method of Database.cs, I find it always return null, So I change the code like following code snap. then I can get the correct result with ******@a.com account
public static async Task<List<T>> ReadAsync<T>() where T : HasId {
using (HttpClient client = new HttpClient ()) {
var res = await client.GetAsync($"{FirebadeDb}{typeof(T).Name.ToLower()}.json");
List<T> objts = new List<T>();
var JsonRes = await res.Content.ReadAsStringAsync();
if (res.IsSuccessStatusCode) {
var valuePairs = JsonConvert.DeserializeObject<Dictionary<string, T>>(JsonRes);
if (valuePairs != null) {
foreach (var item in valuePairs) {
item.Value.Id = item.Key;
objts.Add(item.Value);
}
}
return objts;
} else {
return null;
}
//return null;
}
}
Then, I find you compare book => book.Id == App.UserId in the GetNotebooksAsync method, it is different id. so you always get the null result. so I compare with book => book.UserId == App.UserId like following code snap.
private async void GetNotebooksAsync() {
var notebooks = await Database.ReadAsync<Notebook>();
if (notebooks != null) {
//notebooks = notebooks.Where(book => book.Id == App.UserId).ToList();
notebooks = notebooks.Where(book => book.UserId == App.UserId).ToList();
NotebooksCollection.Clear();
foreach (var item in notebooks)
{
NotebooksCollection.Add(item);
}
}
}
Then I can get the correct result.
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.