Browse Source

Move mapping assignment to Map

Lampan-git 3 months ago
parent
commit
7abb94d8a2
1 changed files with 3 additions and 12 deletions
  1. 3 12
      Jellyfin.Server.Implementations/Item/PeopleRepository.cs

+ 3 - 12
Jellyfin.Server.Implementations/Item/PeopleRepository.cs

@@ -43,18 +43,6 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider, I
         if (!filter.ItemId.IsEmpty())
         if (!filter.ItemId.IsEmpty())
         {
         {
             dbQuery = dbQuery.Include(p => p.BaseItems!.Where(m => m.ItemId == filter.ItemId));
             dbQuery = dbQuery.Include(p => p.BaseItems!.Where(m => m.ItemId == filter.ItemId));
-
-            return dbQuery
-                .AsEnumerable()
-                .Select(p =>
-                {
-                    var personInfo = Map(p);
-                    var mapping = p.BaseItems?.FirstOrDefault();
-                    personInfo.Role = mapping?.Role;
-                    personInfo.SortOrder = mapping?.SortOrder;
-                    return personInfo;
-                })
-                .ToArray();
         }
         }
 
 
         return dbQuery.AsEnumerable().Select(Map).ToArray();
         return dbQuery.AsEnumerable().Select(Map).ToArray();
@@ -111,10 +99,13 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider, I
 
 
     private PersonInfo Map(People people)
     private PersonInfo Map(People people)
     {
     {
+        var mapping = people.BaseItems?.FirstOrDefault();
         var personInfo = new PersonInfo()
         var personInfo = new PersonInfo()
         {
         {
             Id = people.Id,
             Id = people.Id,
             Name = people.Name,
             Name = people.Name,
+            Role = mapping?.Role,
+            SortOrder = mapping?.SortOrder
         };
         };
         if (Enum.TryParse<PersonKind>(people.PersonType, out var kind))
         if (Enum.TryParse<PersonKind>(people.PersonType, out var kind))
         {
         {