| | | 1 | | using Jellyfin.Database.Implementations.Entities; |
| | | 2 | | using Microsoft.EntityFrameworkCore; |
| | | 3 | | using Microsoft.EntityFrameworkCore.Metadata.Builders; |
| | | 4 | | |
| | | 5 | | namespace Jellyfin.Database.Implementations.ModelConfiguration; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// LinkedChildEntity configuration. |
| | | 9 | | /// </summary> |
| | | 10 | | public class LinkedChildConfiguration : IEntityTypeConfiguration<LinkedChildEntity> |
| | | 11 | | { |
| | | 12 | | /// <inheritdoc/> |
| | | 13 | | public void Configure(EntityTypeBuilder<LinkedChildEntity> builder) |
| | | 14 | | { |
| | 2 | 15 | | builder.ToTable("LinkedChildren"); |
| | 2 | 16 | | builder.HasKey(e => new { e.ParentId, e.ChildId }); |
| | 2 | 17 | | builder.HasIndex(e => new { e.ParentId, e.SortOrder }); |
| | 2 | 18 | | builder.HasIndex(e => new { e.ParentId, e.ChildType }); |
| | 2 | 19 | | builder.HasIndex(e => new { e.ChildId, e.ChildType }); |
| | | 20 | | |
| | 2 | 21 | | builder.HasOne(e => e.Parent) |
| | 2 | 22 | | .WithMany(e => e.LinkedChildEntities) |
| | 2 | 23 | | .HasForeignKey(e => e.ParentId) |
| | 2 | 24 | | .OnDelete(DeleteBehavior.NoAction); |
| | | 25 | | |
| | 2 | 26 | | builder.HasOne(e => e.Child) |
| | 2 | 27 | | .WithMany(e => e.LinkedChildOfEntities) |
| | 2 | 28 | | .HasForeignKey(e => e.ChildId) |
| | 2 | 29 | | .OnDelete(DeleteBehavior.NoAction); |
| | 2 | 30 | | } |
| | | 31 | | } |