示例#1
0
        public async Task UpdateRefreshTokenAsync(string email, RefreshToken refreshToken)
        {
            const string sql =
                @"UPDATE Users
SET RefreshToken=@refreshToken
WHERE Email=@email;";

            await using var connection = new SqlConnection(_connectionString);
            await using var command    = new SqlCommand(sql, connection);

            command.Parameters.Add("@email", SqlDbType.NVarChar).Value        = email;
            command.Parameters.Add("@RefreshToken", SqlDbType.NVarChar).Value = refreshToken.AsJsonOrNull();

            await connection.EnsureIsOpenAsync().ConfigureAwait(false);

            await command.ExecuteNonQueryAsync().ConfigureAwait(false);
        }