I have a Xamarin app and I use Cosmos DB on Azure, on the DB side I have this kind of document :
{
"_id" : ObjectId("5b84142d07bf8638bcf7a089"),
"business_id" : "5b81309a7dfa952bb4036f55",
"contentType" : "image",
"media" : "https://fimgs.net/images/perfume/375x500.30796.jpg",
"id" : "22155414-ee2b-3191-c180-3bc9d40db16b"
}
On the Xamarin side, I use the following code :
List<TempObject> TempObjects = new List<TempObject>();
Uri collectionUri = UriFactory.CreateDocumentCollectionUri(_databaseId, _collectionId);
var query = _client.CreateDocumentQuery<TempObject>(collectionUri).AsDocumentQuery();
while (query.HasMoreResults)
{
TempObjects.AddRange( await query.ExecuteNextAsync<TempObject>() );
}
Here is the data class definition :
class TempObject
{
//[JsonProperty(PropertyName = "_id")]
//public string _id { get; set; }
[JsonProperty(PropertyName = "business_id")]
public string business_id { get; set; }
[JsonProperty(PropertyName = "contentType")]
public string contentType { get; set; }
[JsonProperty(PropertyName = "media")]
public string media { get; set; }
[JsonProperty(PropertyName = "id")]
public string id { get; set; }
}
The problem is that it returns the right number of objects, but all the properties are null !
The collection has been created with the default settings and the database is almost empty, only 2 documents in this collection !
The code seems to follow exactly all the tutorials I have found ! Mainly this one : https://docs.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/cosmosdb/consuming
Also, when I use the local CosmosDB emulator with the same database, it works, but not when it is on Azure ! Does it mean that my code is correct and that the issue is on the Azure side ?
Any idea of the issue ? Or a way to debug such kind of problem ?
Thanks
Edit : I have also try with the Cosmonaut API, here is the code:
var cosmosSettings = new CosmosStoreSettings("soclozecosmosdb", "https://soclozedb.documents.azure.com:443/", "E2ipML2QWNVjWITKhX0K0pn7ooCWxbkEk0xkQIC6QIWQCmMjsLU3D2SRTLaIk0dB3bm4k4mWhlpYYpbgsrk2xw==");
ICosmosStore<TempObject> store = new CosmosStore<TempObject>(cosmosSettings);
var users = store.Query().ToList();
But, the query returns 0 objects !
