public async Task <bool> CheckHumanPlayerAsync(Guid playerId, string token) { using (IDbConnection con = new Npgsql.NpgsqlConnection(connectionString)) { return(await con.ExecuteScalarAsync <bool>("SELECT EXISTS (SELECT * FROM users WHERE player_id=@playerId AND payload ->> 'token'=@token)", new { playerId, token })); } }
public async Task <object> Query(Action action) { using (var con = new Npgsql.NpgsqlConnection(_connectionString)) { var result = await con.ExecuteScalarAsync("select pg_sleep(10);"); Console.WriteLine(result); Console.WriteLine("完成"); action(); return(result); } }
public async Task CreateHumanPlayerAsync(Guid playerId, string token) { using (IDbConnection con = new Npgsql.NpgsqlConnection(connectionString)) { await con.ExecuteScalarAsync <bool>( @"INSERT INTO users(is_activated, player_id, player_type, rating, payload) VALUES (false, @playerId, @playerType, @rating, @payload::jsonb)", new { playerId, token, rating = 1000, playerType = PlayerType.Human.ToString(), payload = $@"{{""token"": ""{token}""}}" }); } }