question

Kim Strasser avatar image
Kim Strasser asked

Problem with EntityKey and EntityType when I use SetObjects

I want to write and read a small JSON-serializable object. But I get this message when I use PlayFabDataAPI.SetObjects and I don't know if I should use 'PlayFab.AdminModels.EntityKey' or 'PlayFab.ClientModels.EntityKey'.

'EntityKey' is an ambiguous reference between 'PlayFab.AdminModels.EntityKey' and 'PlayFab.ClientModels.EntityKey'<br>

Should I always use PlayFab.ClientModels.EntityKey in the client code?

In addition, I get this error message:

Error CS0029: Cannot implicitly convert type 'PlayFab.ClientModels.EntityKey' to 'PlayFab.DataModels.EntityKey'
var result = await PlayFabDataAPI.SetObjectsAsync(new PlayFab.DataModels.SetObjectsRequest()
{
    Entity = new PlayFab.ClientModels.EntityKey { Id = EntityID, Type = EntityType },
    Objects = dataList
});

I get EntityID and EntityType when the player calls LoginWithIOSDeviceID:

EntityID = task.Result.Result.EntityToken.Entity.Id;
EntityType = task.Result.Result.EntityToken.Entity.Type;

What am I doing wrong?

Account Management
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

>> Should I always use PlayFab.ClientModels.EntityKey in the client code? What am I doing wrong?

No, in the following code fragment, PlayFab.DataModels.EntityKey should be used instead of PlayFab.ClientModels.EntityKey. PlayFab.DataModels.EntityKey is the predefined C# class for the type of Entity attributes in PlayFabDataAPI.SetObjectsAsync method. So generally PlayFab XXXModels.XXX classes cannot be mixed up.

var result = await PlayFabDataAPI.SetObjectsAsync(new PlayFab.DataModels.SetObjectsRequest()
{
Entity = new PlayFab.DataModels.EntityKey { Id = EntityID, Type = EntityType },
Objects = dataList});
}

The following code fragment is right, the task.Result.Result.EntityToken.Entity is a client entity. You have used this correct client entity’s data but with the wrong type that differs from the predefined type.

EntityID = task.Result.Result.EntityToken.Entity.Id;
EntityType = task.Result.Result.EntityToken.Entity.Type;
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.