Xamarin Database with Kinvey Database

I am using Kinvey db for my project with Xamarin. I am familiar with the functionality of a parse pointer. I want to do the same functionality with Kinvey. Kinvey also has reference functionality. I tried this, but it always saves a null value in kinky db. So I'm really stuck on this. Here is my final result in Kinvey, which stores a null value

Result:      {"type":"KinveyRef","_id":"55f18c9d39d29b9e0f023748","_collection":"Color","_obj":null}

My database model class

[JsonObject(MemberSerialization.OptIn)]
public class Gallery
{
    public Gallery ()
    {
    }

    [JsonProperty("_id")]
    public string ID { get; set; }

    [JsonProperty]
    public string Name { get; set; }

    [JsonProperty]
    public KinveyReference<Color> color;
}


[JsonObject(MemberSerialization.OptIn)]
public class Color
{ 
    public Color ()
    {
    }

    [JsonProperty("_id")]
    public string ID { get; set; }

    [JsonProperty]
    public string Title { get; set; }

    [JsonProperty]
    public string Code { get; set; }

}

Code for storing data in db

 AsyncAppData<Gallery> entityCollection = Client.AppData<User>("Gallery", typeof(Gallery));
            entityCollection.setCache(cache, CachePolicy.CACHE_FIRST);

            AsyncAppData<Color> colorCollection = Client.AppData<Color>("Color", typeof(Color));
            colorCollection.setCache(lcache, CachePolicy.CACHE_FIRST);

            Color color = new Color();
            color.Title = "Pink";
            color.Code = "ff00ff";

            Color colorEnt  = await colorCollection.SaveAsync(color);

            Gallery gallery = new Gallery();
            gallery.Name = "HARSHAD";
            gallery.ID = "1211222as";
            KinveyReference<Color> reference = new KinveyReference<Color>("Color",colorEnt.ID); 
            gallery.color = reference;

            Gallery entity = await entityCollection.SaveAsync(gallery);

Let me know if more details are required.

+4
source share

Source: https://habr.com/ru/post/1606841/


All Articles