diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-12-12 00:52:57 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-12 00:52:57 -0500 |
| commit | d6d0bc71643536f51db596217504b363bcede811 (patch) | |
| tree | 8b227d9884d8c1d3434d355fe8459b3edc22a2ec /Emby.Server.Implementations/Security/AuthenticationRepository.cs | |
| parent | 95b3e08d4b0666f2b437663f38dcafa9183733fb (diff) | |
| parent | 1aff48b93b72fe7d418b4798f504bd0d145f44e8 (diff) | |
Merge pull request #2337 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations/Security/AuthenticationRepository.cs')
| -rw-r--r-- | Emby.Server.Implementations/Security/AuthenticationRepository.cs | 44 |
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 + }; } } } |
