switched to vanilla npgsql for more queries 3
This commit is contained in:
parent
5c9b8e8771
commit
f80dc1ec5d
1 changed files with 13 additions and 6 deletions
|
@ -147,13 +147,20 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers
|
||||||
if (follower == default) throw new ArgumentException("follower");
|
if (follower == default) throw new ArgumentException("follower");
|
||||||
if (follower.Id == default) throw new ArgumentException("id");
|
if (follower.Id == default) throw new ArgumentException("id");
|
||||||
|
|
||||||
var serializedDic = JsonConvert.SerializeObject(follower.FollowingsSyncStatus);
|
var serializedDic = System.Text.Json.JsonSerializer.Serialize(follower.FollowingsSyncStatus);
|
||||||
var query = $"UPDATE {_settings.FollowersTableName} SET followings = @followings, followingsSyncStatus = CAST(@followingsSyncStatus as json), postingErrorCount = @postingErrorCount WHERE id = @id";
|
var query = $"UPDATE {_settings.FollowersTableName} SET followings = $1, followingsSyncStatus = CAST($2 as json), postingErrorCount = $3 WHERE id = $4";
|
||||||
|
await using var connection = DataSource.CreateConnection();
|
||||||
|
await connection.OpenAsync();
|
||||||
|
await using var command = new NpgsqlCommand(query, connection) {
|
||||||
|
Parameters = {
|
||||||
|
new() { Value = follower.Followings},
|
||||||
|
new() { Value = serializedDic},
|
||||||
|
new() { Value = follower.PostingErrorCount},
|
||||||
|
new() { Value = follower.Id}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
using (var dbConnection = Connection)
|
await command.ExecuteNonQueryAsync();
|
||||||
{
|
|
||||||
await dbConnection.QueryAsync(query, new { follower.Id, follower.Followings, followingsSyncStatus = serializedDic, postingErrorCount = follower.PostingErrorCount });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteFollowerAsync(int id)
|
public async Task DeleteFollowerAsync(int id)
|
||||||
|
|
Loading…
Add table
Reference in a new issue