我這邊原本想做batch儲存
但呼叫後會出現奇怪的錯誤
我有一個Endpoint叫UpdateUserData長這樣
[LCEngineFunction(LCConstants.EP_UpdateUserData)]
public static async Task<bool> UpdateUserData(
[LCEngineFunctionParam(LCConstants.Field_email)] string email,
[LCEngineFunctionParam(LCConstants.Field_playerName)] string playerName)
{
List<LCObject> dirtyList = new List<LCObject>();
var curUser = await LCUtil.GetLoginUser();
if (!string.IsNullOrEmpty(email))
{
curUser.Email = email;
dirtyList.Add(curUser);
}
if (!string.IsNullOrEmpty(playerName))
await curUser.SetPlayerName(playerName, dirtyList);
await LCObject.SaveAll(dirtyList); //這個request會報錯
return true;
}
SetPlayerName長這樣
public static async Task<LCUser> SetPlayerName(this LCUser user, string playerName, List<LCObject> dirtyList)
{
var lcObj = await user.GetRecord<AccountDataRecord>();
if (lcObj == null)
{
throw LCErrorUtil.LookUpException(LCError.ParamAbnormal, "accountData is null");
}
else
{
lcObj[LCConstants.Field_playerName] = playerName;
dirtyList.Add(lcObj);
}
return user;
}
GetRecord長這樣
public static async Task<LCObject> GetRecord<T>(this LCUser user)
{
var recordType = typeof(T);
string recordKey = LCConstants.typeNameMap[recordType];
var obj = user[recordKey];
if (obj is LCObject)
{
var lcObj = obj as LCObject;
Debug.Log("is LCObj, objID:" + lcObj.ObjectId + ",class:" + lcObj.ClassName);
return lcObj;
}
else if (obj is string) //objectID
{
Debug.Log("objID:" + obj);
return await LCUtil.GetQuery<T>().Get(obj as string);
}
else
{
Debug.LogError("unknown data for recordType:" + recordType.Name);
return null;
}
}
目前得知的訊息是GetRecord那邊他會跑obj is LCObject這個branch的邏輯 這裡看起來符合預期取到對的LCObject
然後也能順利設定PlayerName 但是要進行batch儲存時(SaveAll)的request就會爆一個錯 這個錯長這樣
他說 Could not find object by id AccountDataRecord for class AccountDataRecord這讓我感到有點困惑不知道這句話的意思是?
-
创建时间
21年9月29日
-
最后回复
22年7月12日
-
9
回复
-
1.8K
浏览
-
4
用户
-
1
链接