| | | 1 | | using AsiBackbone.EntityFrameworkCore.Persistence; |
| | | 2 | | using Microsoft.EntityFrameworkCore; |
| | | 3 | | using Microsoft.EntityFrameworkCore.Metadata.Builders; |
| | | 4 | | |
| | | 5 | | namespace AsiBackbone.EntityFrameworkCore.Configurations; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Configures the Entity Framework Core persistence mapping for <see cref="AsiBackboneHandshakeRequestEntity" />. |
| | | 9 | | /// </summary> |
| | | 10 | | public sealed class AsiBackboneHandshakeRequestEntityConfiguration |
| | | 11 | | : IEntityTypeConfiguration<AsiBackboneHandshakeRequestEntity> |
| | | 12 | | { |
| | | 13 | | private const int IdentifierMaxLength = 128; |
| | | 14 | | private const int SchemaVersionMaxLength = 64; |
| | | 15 | | private const int DisplayNameMaxLength = 256; |
| | | 16 | | private const int OperationNameMaxLength = 256; |
| | | 17 | | private const int ActorTypeMaxLength = 64; |
| | | 18 | | private const int ReasonCodeMaxLength = 256; |
| | | 19 | | private const int AcknowledgmentCodeMaxLength = 128; |
| | | 20 | | private const int RiskLevelMaxLength = 64; |
| | | 21 | | private const int RiskCategoryMaxLength = 128; |
| | | 22 | | private const int CorrelationMaxLength = 128; |
| | | 23 | | private const int PolicyVersionMaxLength = 128; |
| | | 24 | | private const int HashMaxLength = 512; |
| | | 25 | | private const int ConcurrencyStampMaxLength = 64; |
| | | 26 | | |
| | | 27 | | /// <inheritdoc /> |
| | | 28 | | public void Configure(EntityTypeBuilder<AsiBackboneHandshakeRequestEntity> builder) |
| | | 29 | | { |
| | 22 | 30 | | ArgumentNullException.ThrowIfNull(builder); |
| | | 31 | | |
| | 22 | 32 | | _ = builder.ToTable("AsiBackboneHandshakeRequests"); |
| | | 33 | | |
| | 22 | 34 | | _ = builder.HasKey(request => request.Id); |
| | | 35 | | |
| | 22 | 36 | | _ = builder.Property(request => request.Id) |
| | 22 | 37 | | .ValueGeneratedNever(); |
| | | 38 | | |
| | 22 | 39 | | _ = builder.Property(request => request.ConcurrencyStamp) |
| | 22 | 40 | | .IsRequired() |
| | 22 | 41 | | .HasMaxLength(ConcurrencyStampMaxLength) |
| | 22 | 42 | | .IsConcurrencyToken(); |
| | | 43 | | |
| | 22 | 44 | | _ = builder.Property(request => request.HandshakeId) |
| | 22 | 45 | | .IsRequired() |
| | 22 | 46 | | .HasMaxLength(IdentifierMaxLength); |
| | | 47 | | |
| | 22 | 48 | | _ = builder.Property(request => request.SchemaVersion) |
| | 22 | 49 | | .IsRequired() |
| | 22 | 50 | | .HasMaxLength(SchemaVersionMaxLength); |
| | | 51 | | |
| | 22 | 52 | | _ = builder.Property(request => request.ActorId) |
| | 22 | 53 | | .IsRequired() |
| | 22 | 54 | | .HasMaxLength(IdentifierMaxLength); |
| | | 55 | | |
| | 22 | 56 | | _ = builder.Property(request => request.ActorType) |
| | 22 | 57 | | .HasConversion<string>() |
| | 22 | 58 | | .IsRequired() |
| | 22 | 59 | | .HasMaxLength(ActorTypeMaxLength); |
| | | 60 | | |
| | 22 | 61 | | _ = builder.Property(request => request.ActorDisplayName) |
| | 22 | 62 | | .HasMaxLength(DisplayNameMaxLength); |
| | | 63 | | |
| | 22 | 64 | | _ = builder.Property(request => request.OperationName) |
| | 22 | 65 | | .IsRequired() |
| | 22 | 66 | | .HasMaxLength(OperationNameMaxLength); |
| | | 67 | | |
| | 22 | 68 | | _ = builder.Property(request => request.ReasonCode) |
| | 22 | 69 | | .IsRequired() |
| | 22 | 70 | | .HasMaxLength(ReasonCodeMaxLength); |
| | | 71 | | |
| | 22 | 72 | | _ = builder.Property(request => request.Message) |
| | 22 | 73 | | .IsRequired(); |
| | | 74 | | |
| | 22 | 75 | | _ = builder.Property(request => request.RequiredAcknowledgmentCode) |
| | 22 | 76 | | .IsRequired() |
| | 22 | 77 | | .HasMaxLength(AcknowledgmentCodeMaxLength); |
| | | 78 | | |
| | 22 | 79 | | _ = builder.Property(request => request.RequiredAcknowledgmentText) |
| | 22 | 80 | | .IsRequired(); |
| | | 81 | | |
| | 22 | 82 | | _ = builder.Property(request => request.RiskLevel) |
| | 22 | 83 | | .HasConversion<string>() |
| | 22 | 84 | | .IsRequired() |
| | 22 | 85 | | .HasMaxLength(RiskLevelMaxLength); |
| | | 86 | | |
| | 22 | 87 | | _ = builder.Property(request => request.RiskCategory) |
| | 22 | 88 | | .HasMaxLength(RiskCategoryMaxLength); |
| | | 89 | | |
| | 22 | 90 | | _ = builder.Property(request => request.CorrelationId) |
| | 22 | 91 | | .HasMaxLength(CorrelationMaxLength); |
| | | 92 | | |
| | 22 | 93 | | _ = builder.Property(request => request.TraceId) |
| | 22 | 94 | | .HasMaxLength(CorrelationMaxLength); |
| | | 95 | | |
| | 22 | 96 | | _ = builder.Property(request => request.PolicyVersion) |
| | 22 | 97 | | .HasMaxLength(PolicyVersionMaxLength); |
| | | 98 | | |
| | 22 | 99 | | _ = builder.Property(request => request.PolicyHash) |
| | 22 | 100 | | .HasMaxLength(HashMaxLength); |
| | | 101 | | |
| | 22 | 102 | | _ = builder.HasIndex(request => request.HandshakeId) |
| | 22 | 103 | | .IsUnique(); |
| | | 104 | | |
| | 22 | 105 | | _ = builder.HasIndex(request => request.SchemaVersion); |
| | | 106 | | |
| | 22 | 107 | | _ = builder.HasIndex(request => request.ActorId); |
| | | 108 | | |
| | 22 | 109 | | _ = builder.HasIndex(request => request.ActorType); |
| | | 110 | | |
| | 22 | 111 | | _ = builder.HasIndex(request => request.OperationName); |
| | | 112 | | |
| | 22 | 113 | | _ = builder.HasIndex(request => request.ReasonCode); |
| | | 114 | | |
| | 22 | 115 | | _ = builder.HasIndex(request => request.RequiredAcknowledgmentCode); |
| | | 116 | | |
| | 22 | 117 | | _ = builder.HasIndex(request => request.RiskLevel); |
| | | 118 | | |
| | 22 | 119 | | _ = builder.HasIndex(request => request.RiskCategory); |
| | | 120 | | |
| | 22 | 121 | | _ = builder.HasIndex(request => request.CorrelationId); |
| | | 122 | | |
| | 22 | 123 | | _ = builder.HasIndex(request => request.TraceId); |
| | | 124 | | |
| | 22 | 125 | | _ = builder.HasIndex(request => request.PolicyVersion); |
| | | 126 | | |
| | 22 | 127 | | _ = builder.HasIndex(request => request.PolicyHash); |
| | | 128 | | |
| | 22 | 129 | | _ = builder.HasIndex(request => new |
| | 22 | 130 | | { |
| | 22 | 131 | | request.ActorId, |
| | 22 | 132 | | request.OperationName |
| | 22 | 133 | | }); |
| | | 134 | | |
| | 22 | 135 | | _ = builder.HasIndex(request => new |
| | 22 | 136 | | { |
| | 22 | 137 | | request.CorrelationId, |
| | 22 | 138 | | request.OperationName |
| | 22 | 139 | | }); |
| | | 140 | | |
| | 22 | 141 | | _ = builder.HasIndex(request => new |
| | 22 | 142 | | { |
| | 22 | 143 | | request.PolicyVersion, |
| | 22 | 144 | | request.PolicyHash |
| | 22 | 145 | | }); |
| | 22 | 146 | | } |
| | | 147 | | } |