0
votes

My app uses Azure Mobile Services (.NET Backend), and I can write data in the DB with no problems at all.

The problem is this: when I try to read data with ToCollectionAsync() called on a MobileServiceTable object I receive a null object. It should not be null, since there is some data in the table.

What might be the reason? The domain class on mobile service is identical to the "local" domain class. If this is not sufficiently weird, please consider this: after inserting an element in the table the ToCollectionAsync() returns a non empty collection. To refresh the data I call await tableVar.ToCollectionAsync(); Any idea?

1

1 Answers

0
votes

Solved. The problem was due to what seems to be a strange way of loading objects. If I update the item list in a method:

private void RefreshItems()
{
   this.items= await itemTable.ToCollectionAsync<ItemModel>();
}

The items variable remains null, but if I write that instruction in the same method in which I use the variable it's not null.