aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-12-13 13:27:53 -0500
committerGitHub <noreply@github.com>2016-12-13 13:27:53 -0500
commit6cdbb25b9d756b58806414455cc4c4d1bc555217 (patch)
treeb6bc4f10ad1c6f758215a719b2be932b5979e896 /Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
parentb33dcdf7bd61a8096928e1b2b5e34af1c8373096 (diff)
parentffad9c27e4844eeab235f88cb45739370d22a83a (diff)
Merge pull request #2340 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations/Data/SqliteUserDataRepository.cs')
-rw-r--r--Emby.Server.Implementations/Data/SqliteUserDataRepository.cs30
1 files changed, 13 insertions, 17 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
index 7afb5720e..2e39b038a 100644
--- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
@@ -42,8 +42,10 @@ namespace Emby.Server.Implementations.Data
/// Opens the connection to the database
/// </summary>
/// <returns>Task.</returns>
- public void Initialize(ReaderWriterLockSlim writeLock)
+ public void Initialize(ReaderWriterLockSlim writeLock, ManagedConnection managedConnection)
{
+ _connection = managedConnection;
+
WriteLock.Dispose();
WriteLock = writeLock;
@@ -90,7 +92,7 @@ namespace Emby.Server.Implementations.Data
}
}
- private void ImportUserDataIfNeeded(IDatabaseConnection connection)
+ private void ImportUserDataIfNeeded(ManagedConnection connection)
{
if (!_fileSystem.FileExists(_importFile))
{
@@ -117,7 +119,7 @@ namespace Emby.Server.Implementations.Data
}, TransactionMode);
}
- private void ImportUserData(IDatabaseConnection connection, string file)
+ private void ImportUserData(ManagedConnection connection, string file)
{
SqliteExtensions.Attach(connection, file, "UserDataBackup");
@@ -300,24 +302,18 @@ namespace Emby.Server.Implementations.Data
{
using (var connection = CreateConnection(true))
{
- UserItemData result = null;
-
- connection.RunInTransaction(db =>
+ using (var statement = connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where key =@Key and userId=@UserId"))
{
- using (var statement = db.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where key =@Key and userId=@UserId"))
+ statement.TryBind("@UserId", userId.ToGuidParamValue());
+ statement.TryBind("@Key", key);
+
+ foreach (var row in statement.ExecuteQuery())
{
- statement.TryBind("@UserId", userId.ToGuidParamValue());
- statement.TryBind("@Key", key);
-
- foreach (var row in statement.ExecuteQuery())
- {
- result = ReadRow(row);
- break;
- }
+ return ReadRow(row);
}
- }, ReadTransactionMode);
+ }
- return result;
+ return null;
}
}
}