BaseItemConfiguration.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using Jellyfin.Data.Entities;
  3. using Microsoft.EntityFrameworkCore;
  4. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  5. namespace Jellyfin.Server.Implementations.ModelConfiguration;
  6. /// <summary>
  7. /// Configuration for BaseItem.
  8. /// </summary>
  9. public class BaseItemConfiguration : IEntityTypeConfiguration<BaseItemEntity>
  10. {
  11. /// <inheritdoc/>
  12. public void Configure(EntityTypeBuilder<BaseItemEntity> builder)
  13. {
  14. builder.HasNoKey();
  15. builder.HasIndex(e => e.Path);
  16. builder.HasIndex(e => e.ParentId);
  17. builder.HasIndex(e => e.PresentationUniqueKey);
  18. builder.HasIndex(e => new { e.Id, e.Type, e.IsFolder, e.IsVirtualItem });
  19. builder.HasIndex(e => new { e.UserDataKey, e.Type });
  20. // covering index
  21. builder.HasIndex(e => new { e.TopParentId, e.Id });
  22. // series
  23. builder.HasIndex(e => new { e.Type, e.SeriesPresentationUniqueKey, e.PresentationUniqueKey, e.SortName });
  24. // series counts
  25. // seriesdateplayed sort order
  26. builder.HasIndex(e => new { e.Type, e.SeriesPresentationUniqueKey, e.IsFolder, e.IsVirtualItem });
  27. // live tv programs
  28. builder.HasIndex(e => new { e.Type, e.TopParentId, e.StartDate });
  29. // covering index for getitemvalues
  30. builder.HasIndex(e => new { e.Type, e.TopParentId, e.Id });
  31. // used by movie suggestions
  32. builder.HasIndex(e => new { e.Type, e.TopParentId, e.PresentationUniqueKey });
  33. // latest items
  34. builder.HasIndex(e => new { e.Type, e.TopParentId, e.IsVirtualItem, e.PresentationUniqueKey, e.DateCreated });
  35. builder.HasIndex(e => new { e.IsFolder, e.TopParentId, e.IsVirtualItem, e.PresentationUniqueKey, e.DateCreated });
  36. // resume
  37. builder.HasIndex(e => new { e.MediaType, e.TopParentId, e.IsVirtualItem, e.PresentationUniqueKey });
  38. }
  39. }