aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Security/AuthenticationRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Security/AuthenticationRepository.cs')
-rw-r--r--Emby.Server.Implementations/Security/AuthenticationRepository.cs44
1 files changed, 28 insertions, 16 deletions
diff --git a/Emby.Server.Implementations/Security/AuthenticationRepository.cs b/Emby.Server.Implementations/Security/AuthenticationRepository.cs
index dbca4931b..a136701da 100644
--- a/Emby.Server.Implementations/Security/AuthenticationRepository.cs
+++ b/Emby.Server.Implementations/Security/AuthenticationRepository.cs
@@ -201,35 +201,47 @@ namespace Emby.Server.Implementations.Security
}
var list = new List<AuthenticationInfo>();
+ int totalRecordCount = 0;
using (WriteLock.Read())
{
using (var connection = CreateConnection(true))
{
- using (var statement = connection.PrepareStatement(commandText))
+ connection.RunInTransaction(db =>
{
- BindAuthenticationQueryParams(query, statement);
+ var statementTexts = new List<string>();
+ statementTexts.Add(commandText);
+ statementTexts.Add("select count (Id) from AccessTokens" + whereTextWithoutPaging);
- foreach (var row in statement.ExecuteQuery())
- {
- list.Add(Get(row));
- }
+ var statements = PrepareAllSafe(db, string.Join(";", statementTexts.ToArray()))
+ .ToList();
- using (var totalCountStatement = connection.PrepareStatement("select count (Id) from AccessTokens" + whereTextWithoutPaging))
+ using (var statement = statements[0])
{
- BindAuthenticationQueryParams(query, totalCountStatement);
+ BindAuthenticationQueryParams(query, statement);
- var count = totalCountStatement.ExecuteQuery()
- .SelectScalarInt()
- .First();
+ foreach (var row in statement.ExecuteQuery())
+ {
+ list.Add(Get(row));
+ }
- return new QueryResult<AuthenticationInfo>()
+ using (var totalCountStatement = statements[1])
{
- Items = list.ToArray(),
- TotalRecordCount = count
- };
+ BindAuthenticationQueryParams(query, totalCountStatement);
+
+ totalRecordCount = totalCountStatement.ExecuteQuery()
+ .SelectScalarInt()
+ .First();
+ }
}
- }
+
+ }, ReadTransactionMode);
+
+ return new QueryResult<AuthenticationInfo>()
+ {
+ Items = list.ToArray(),
+ TotalRecordCount = totalRecordCount
+ };
}
}
}