diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-11-20 15:32:24 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-20 15:32:24 -0500 |
| commit | 2ea0f7c545879b7bde976a783d923c0078003bf2 (patch) | |
| tree | 15991ef523281ee1577b685616d22fc9953c13f9 /Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs | |
| parent | af7de0a35346270e5cca7c6998e1608dfdcf9d1d (diff) | |
| parent | 24dc91160d33e9b1ea8edd1f4262b8ecb14db930 (diff) | |
Merge pull request #2297 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs')
| -rw-r--r-- | Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs index 1fbf9b0a9..184caa4d4 100644 --- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs @@ -100,14 +100,17 @@ namespace Emby.Server.Implementations.Data private void SaveDisplayPreferences(DisplayPreferences displayPreferences, Guid userId, string client, IDatabaseConnection connection) { - var commandText = "replace into userdisplaypreferences (id, userid, client, data) values (?, ?, ?, ?)"; - var serialized = _jsonSerializer.SerializeToBytes(displayPreferences, _memoryStreamProvider); - - connection.Execute(commandText, - displayPreferences.Id.ToGuidParamValue(), - userId.ToGuidParamValue(), - client, - serialized); + using (var statement = connection.PrepareStatement("replace into userdisplaypreferences (id, userid, client, data) values (@id, @userid, @client, @data)")) + { + var serialized = _jsonSerializer.SerializeToBytes(displayPreferences, _memoryStreamProvider); + + statement.TryBind("@id", displayPreferences.Id.ToGuidParamValue()); + statement.TryBind("@userId", userId.ToGuidParamValue()); + statement.TryBind("@client", client); + statement.TryBind("@data", serialized); + + statement.MoveNext(); + } } /// <summary> @@ -163,16 +166,16 @@ namespace Emby.Server.Implementations.Data { using (var connection = CreateConnection(true)) { - var commandText = "select data from userdisplaypreferences where id = ? and userId=? and client=?"; - - var paramList = new List<object>(); - paramList.Add(guidId.ToGuidParamValue()); - paramList.Add(userId.ToGuidParamValue()); - paramList.Add(client); - - foreach (var row in connection.Query(commandText, paramList.ToArray())) + using (var statement = connection.PrepareStatement("select data from userdisplaypreferences where id = @id and userId=@userId and client=@client")) { - return Get(row); + statement.TryBind("@id", guidId.ToGuidParamValue()); + statement.TryBind("@userId", userId.ToGuidParamValue()); + statement.TryBind("@client", client); + + foreach (var row in statement.ExecuteQuery()) + { + return Get(row); + } } return new DisplayPreferences @@ -197,14 +200,14 @@ namespace Emby.Server.Implementations.Data { using (var connection = CreateConnection(true)) { - var commandText = "select data from userdisplaypreferences where userId=?"; - - var paramList = new List<object>(); - paramList.Add(userId.ToGuidParamValue()); - - foreach (var row in connection.Query(commandText, paramList.ToArray())) + using (var statement = connection.PrepareStatement("select data from userdisplaypreferences where userId=@userId")) { - list.Add(Get(row)); + statement.TryBind("@userId", userId.ToGuidParamValue()); + + foreach (var row in statement.ExecuteQuery()) + { + list.Add(Get(row)); + } } } } |
