aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs')
-rw-r--r--Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs51
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..1c592048e 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.BindParameters.TryBind("@id", displayPreferences.Id.ToGuidParamValue());
+ statement.BindParameters.TryBind("@userId", userId.ToGuidParamValue());
+ statement.BindParameters.TryBind("@client", client);
+ statement.BindParameters.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.BindParameters.TryBind("@id", guidId.ToGuidParamValue());
+ statement.BindParameters.TryBind("@userId", userId.ToGuidParamValue());
+ statement.BindParameters.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.BindParameters.TryBind("@userId", userId.ToGuidParamValue());
+
+ foreach (var row in statement.ExecuteQuery())
+ {
+ list.Add(Get(row));
+ }
}
}
}