Start a new topic

How to resolve KinveyReference in Xamarin

 Hi


I have a collection called "Occupation", an Occupation can have multiple "Available Skills". The Skills are stored in their own Collection called "Skill". I have defined my Occupation entity object as follows:


    public class Occupation : EntityBase
    {
        public static string CollectionName = "Occupation";

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

        [JsonProperty]
        public List<KinveyReference<Skill>> AvailableSkills { get; set; }

        public Occupation() : base()
        {
         
            AvailableSkills = new List<KinveyReference<Skill>>();
        }
    }


I have managed to add a Skill to the AvailableSkills list, and that is persisted on the server without issue. My problem is however, when I retrieve the occupation entity, the "resolved" property of the KinveyReference is null. What is the best way to resolve the reference so that I can get the actual skill object when I retrieve the occupation object?


Any help would be greatly appreciated.


Thanks


Jacob





Hi Jacob,


I am looking into this now. I have also involved a colleague who has some Xamarin experience.


Can you paste the code you are using to fetch occupation entities?



Regards,

Wani

Kinvey Support

Hi Wani

This is the code that I'm using:

        public async Task<List<Occupation>> GetOccupations()
        {
            var occupations = await _service.FetchAllEntities<Occupation>(Occupation.CollectionName);
            
            return occupations.ToList();
        }

 

The FetchAllEntities method looks like this:


public async Task<T[]> FetchAllEntities<T>(string collectionName)
{
    return await Client.AppData<T>(collectionName, typeof(T)).GetAsync();
}

 

 As mentioned before, I get a List of KinveyReferences back, but the resolvedEntity property is null on each of the items in the list. I tried calling getResolvedEntity() on each of the objects in the list, but they come back as null as well.

 

 

 

Login or Signup to post a comment