/// <summary> /// 获取用户ID /// </summary> /// <param name="strs">第一个参数为Token,第二个参数可选,比如根据Platform有不同Token</param> /// <returns></returns> public async Task <string> GetUid(params string[] strs) { var request = GetRequest(strs); using Sqless sqless = new Sqless(SqlessConfig); var uid = await sqless.SelectFirstOrDefault <string>(request); if (string.IsNullOrEmpty(uid)) { throw new SqlessUnauthorizedAccessException(); } return(uid); }
public async Task UpdateOwnerFieldTest() { var updateRequest = new SqlessEditRequest() { Table = Tables.User, Fields = new List <SqlessEditField>() { new SqlessEditField() { Field = "Uid", Value = "2", Type = System.Data.DbType.String } } }; using Sqless updateSqless = new Sqless(Global.GetOwnerAccessConfig("1")); var updateResult = await updateSqless.Update(updateRequest); Assert.IsTrue(updateResult > 0); var selectRequest = new SqlessSelectRequest() { Table = Tables.User, Fields = new List <Query.SqlessField>() { new SqlessField() { Field = "Uid" } } }; using Sqless selectSqless = new Sqless(Global.GetOwnerAccessConfig("1")); var selectResult = await selectSqless.SelectFirstOrDefault <string>(selectRequest); Assert.AreEqual(selectResult, "1"); }