4

I'm using Kinvey db for my project with Xamarin. I familiar with parse pointer functionality. I want to do the same functionality with Kinvey. Kinvey has reference functionality too. I tried that but it always store the null value in kinky db. So I'm really stuck on this. Here is my final result in Kinvey, which stores 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 to store the data in db is

 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 require more detail.

Harshadcse
  • 225
  • 1
  • 9

0 Answers0