mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-01 04:34:26 -04:00
Wrap context creation with using
This commit is contained in:
parent
52ebf6ae8f
commit
8a9ec7809f
@ -2,6 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Jellyfin.Data.Entities;
|
using Jellyfin.Data.Entities;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace Jellyfin.Server.Implementations.Users
|
namespace Jellyfin.Server.Implementations.Users
|
||||||
{
|
{
|
||||||
@ -24,7 +25,7 @@ namespace Jellyfin.Server.Implementations.Users
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public DisplayPreferences GetDisplayPreferences(Guid userId, string client)
|
public DisplayPreferences GetDisplayPreferences(Guid userId, string client)
|
||||||
{
|
{
|
||||||
var dbContext = _dbProvider.CreateContext();
|
using var dbContext = _dbProvider.CreateContext();
|
||||||
var user = dbContext.Users.Find(userId);
|
var user = dbContext.Users.Find(userId);
|
||||||
#pragma warning disable CA1307
|
#pragma warning disable CA1307
|
||||||
var prefs = user.DisplayPreferences.FirstOrDefault(pref => string.Equals(pref.Client, client));
|
var prefs = user.DisplayPreferences.FirstOrDefault(pref => string.Equals(pref.Client, client));
|
||||||
@ -41,7 +42,7 @@ namespace Jellyfin.Server.Implementations.Users
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void SaveChanges(DisplayPreferences preferences)
|
public void SaveChanges(DisplayPreferences preferences)
|
||||||
{
|
{
|
||||||
var dbContext = _dbProvider.CreateContext();
|
using var dbContext = _dbProvider.CreateContext();
|
||||||
dbContext.Update(preferences);
|
dbContext.Update(preferences);
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user