mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-24 02:02:29 -04:00
Updated .AsNoTracking() where applicable
This commit is contained in:
parent
fe9c96d052
commit
2c2e33dd82
@ -233,7 +233,7 @@ public sealed class BaseItemRepository(IDbContextFactory<JellyfinDbContext> dbPr
|
||||
var result = new QueryResult<BaseItemDto>();
|
||||
|
||||
using var context = dbProvider.CreateDbContext();
|
||||
IQueryable<BaseItemEntity> dbQuery = context.BaseItems
|
||||
IQueryable<BaseItemEntity> dbQuery = context.BaseItems.AsNoTracking()
|
||||
.Include(e => e.ExtraType)
|
||||
.Include(e => e.TrailerTypes)
|
||||
.Include(e => e.Images)
|
||||
@ -272,7 +272,7 @@ public sealed class BaseItemRepository(IDbContextFactory<JellyfinDbContext> dbPr
|
||||
PrepareFilterQuery(filter);
|
||||
|
||||
using var context = dbProvider.CreateDbContext();
|
||||
var dbQuery = TranslateQuery(context.BaseItems, context, filter);
|
||||
var dbQuery = TranslateQuery(context.BaseItems.AsNoTracking(), context, filter);
|
||||
if (filter.Limit.HasValue || filter.StartIndex.HasValue)
|
||||
{
|
||||
var offset = filter.StartIndex ?? 0;
|
||||
@ -299,7 +299,7 @@ public sealed class BaseItemRepository(IDbContextFactory<JellyfinDbContext> dbPr
|
||||
PrepareFilterQuery(filter);
|
||||
|
||||
using var context = dbProvider.CreateDbContext();
|
||||
var dbQuery = TranslateQuery(context.BaseItems, context, filter);
|
||||
var dbQuery = TranslateQuery(context.BaseItems.AsNoTracking(), context, filter);
|
||||
|
||||
return dbQuery.Count();
|
||||
}
|
||||
@ -1310,7 +1310,7 @@ public sealed class BaseItemRepository(IDbContextFactory<JellyfinDbContext> dbPr
|
||||
}
|
||||
|
||||
using var context = dbProvider.CreateDbContext();
|
||||
var item = context.BaseItems.FirstOrDefault(e => e.Id == id);
|
||||
var item = context.BaseItems.AsNoTracking().FirstOrDefault(e => e.Id == id);
|
||||
if (item is null)
|
||||
{
|
||||
return null;
|
||||
@ -1644,6 +1644,7 @@ public sealed class BaseItemRepository(IDbContextFactory<JellyfinDbContext> dbPr
|
||||
using var context = dbProvider.CreateDbContext();
|
||||
|
||||
var query = context.ItemValues
|
||||
.AsNoTracking()
|
||||
.Where(e => itemValueTypes.Any(w => (ItemValueType)w == e.Type));
|
||||
if (withItemTypes.Count > 0)
|
||||
{
|
||||
@ -1693,7 +1694,7 @@ public sealed class BaseItemRepository(IDbContextFactory<JellyfinDbContext> dbPr
|
||||
IsNews = filter.IsNews,
|
||||
IsSeries = filter.IsSeries
|
||||
};
|
||||
var query = TranslateQuery(context.BaseItems, context, innerQuery);
|
||||
var query = TranslateQuery(context.BaseItems.AsNoTracking(), context, innerQuery);
|
||||
|
||||
query = query.Where(e => e.Type == returnType && e.ItemValues!.Any(f => e.CleanName == f.CleanValue && itemValueTypes.Any(w => (ItemValueType)w == f.Type)));
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class ChapterRepository : IChapterRepository
|
||||
public ChapterInfo? GetChapter(Guid baseItemId, int index)
|
||||
{
|
||||
using var context = _dbProvider.CreateDbContext();
|
||||
var chapter = context.Chapters
|
||||
var chapter = context.Chapters.AsNoTracking()
|
||||
.Select(e => new
|
||||
{
|
||||
chapter = e,
|
||||
@ -65,7 +65,7 @@ public class ChapterRepository : IChapterRepository
|
||||
public IReadOnlyList<ChapterInfo> GetChapters(Guid baseItemId)
|
||||
{
|
||||
using var context = _dbProvider.CreateDbContext();
|
||||
return context.Chapters.Where(e => e.ItemId.Equals(baseItemId))
|
||||
return context.Chapters.AsNoTracking().Where(e => e.ItemId.Equals(baseItemId))
|
||||
.Select(e => new
|
||||
{
|
||||
chapter = e,
|
||||
|
@ -34,7 +34,7 @@ public class MediaAttachmentRepository(IDbContextFactory<JellyfinDbContext> dbPr
|
||||
public IReadOnlyList<MediaAttachment> GetMediaAttachments(MediaAttachmentQuery filter)
|
||||
{
|
||||
using var context = dbProvider.CreateDbContext();
|
||||
var query = context.AttachmentStreamInfos.Where(e => e.ItemId.Equals(filter.ItemId));
|
||||
var query = context.AttachmentStreamInfos.AsNoTracking().Where(e => e.ItemId.Equals(filter.ItemId));
|
||||
if (filter.Index.HasValue)
|
||||
{
|
||||
query = query.Where(e => e.Index == filter.Index);
|
||||
|
@ -37,7 +37,7 @@ public class MediaStreamRepository(IDbContextFactory<JellyfinDbContext> dbProvid
|
||||
public IReadOnlyList<MediaStream> GetMediaStreams(MediaStreamQuery filter)
|
||||
{
|
||||
using var context = dbProvider.CreateDbContext();
|
||||
return TranslateQuery(context.MediaStreamInfos, filter).AsEnumerable().Select(Map).ToImmutableArray();
|
||||
return TranslateQuery(context.MediaStreamInfos.AsNoTracking(), filter).AsEnumerable().Select(Map).ToImmutableArray();
|
||||
}
|
||||
|
||||
private string? GetPathToSave(string? path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user