diff options
| author | KGT1 <kilian.gamn@gmx.de> | 2026-05-03 22:35:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-03 22:35:57 +0200 |
| commit | 4464b2e2ed9d8cc3f4c520ee76dfedac3557cf0d (patch) | |
| tree | 4fdf6dc5fff74c21b3b2cd74c1d3d5fd695b0638 /src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/LinkedChildConfiguration.cs | |
| parent | 950c6525d1ab456115c4ee80b8fed86c5a81eaf5 (diff) | |
| parent | 622947e37425f3620432995cde5d4a0809d91694 (diff) | |
Merge branch 'jellyfin:master' into removeGenericConfigurationEndpoint
Diffstat (limited to 'src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/LinkedChildConfiguration.cs')
| -rw-r--r-- | src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/LinkedChildConfiguration.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/LinkedChildConfiguration.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/LinkedChildConfiguration.cs new file mode 100644 index 0000000000..2abccd41f0 --- /dev/null +++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/LinkedChildConfiguration.cs @@ -0,0 +1,31 @@ +using Jellyfin.Database.Implementations.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace Jellyfin.Database.Implementations.ModelConfiguration; + +/// <summary> +/// LinkedChildEntity configuration. +/// </summary> +public class LinkedChildConfiguration : IEntityTypeConfiguration<LinkedChildEntity> +{ + /// <inheritdoc/> + public void Configure(EntityTypeBuilder<LinkedChildEntity> builder) + { + builder.ToTable("LinkedChildren"); + builder.HasKey(e => new { e.ParentId, e.ChildId }); + builder.HasIndex(e => new { e.ParentId, e.SortOrder }); + builder.HasIndex(e => new { e.ParentId, e.ChildType }); + builder.HasIndex(e => new { e.ChildId, e.ChildType }); + + builder.HasOne(e => e.Parent) + .WithMany(e => e.LinkedChildEntities) + .HasForeignKey(e => e.ParentId) + .OnDelete(DeleteBehavior.NoAction); + + builder.HasOne(e => e.Child) + .WithMany(e => e.LinkedChildOfEntities) + .HasForeignKey(e => e.ChildId) + .OnDelete(DeleteBehavior.NoAction); + } +} |
