| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using Microsoft.EntityFrameworkCore;
- using Quadarax.Application.QLiberace.Common.Entities.Base.DaoMapper;
- namespace Quadarax.Application.QLiberace.Base.Entities.DaoMapper
- {
- internal class SettingDm : TrackedDm<Setting>
- {
- public override void Map(ModelBuilder builder)
- {
- if (builder == null) throw new ArgumentNullException(nameof(builder));
- base.Map(builder);
- builder.Entity<Setting>(entity =>
- {
-
- entity.ToTable(Constants.Modules.Base.TblSetting, Constants.Modules.Base.Schema);
- // indexes
- entity.HasIndex(e => new { e.TenantId, e.ModuleCode, e.Code }, "IDX_SETTING_TENANT_MCODE_CODE")
- .IsUnique();
- // foreign keys
- entity.Property(e => e.TenantId).IsRequired().HasComment("Reference to tenant that setting belongs");
- entity.Property(e => e.ParentId).HasComment("Reference to parent setting");
-
- // columns
- entity.Property(e => e.Code).IsRequired()
- .HasMaxLength(100)
- .HasComment("Setting code. Main key to search.");
-
- entity.Property(e => e.Description)
- .HasMaxLength(500)
- .HasComment("Setting value description");
- entity.Property(e => e.IsEnabled).IsRequired()
- .HasDefaultValueSql("0").HasComment("Flag if setting is enabled");
-
- entity.Property(e => e.ModuleCode).IsRequired()
- .HasMaxLength(10)
- .HasComment("Module code that setting belongs. Secondary key");
-
- entity.Property(e => e.SequenceNo).IsRequired()
- .HasDefaultValueSql("0")
- .HasComment("Order number");
- entity.Property(e => e.Value)
- .HasComment("Setting value");
- entity.Property(e => e.ValueTypeQualified).IsRequired()
- .HasMaxLength(500)
- .HasComment("Qualified name of value type");
- /*
- entity.HasOne(d => d.Parent)
- .WithMany(p => p.InverseParent)
- .HasForeignKey(d => d.ParentId)
- .HasConstraintName("REL_SETTING_SETTING_ID");
- entity.HasOne(d => d.Tenant)
- .WithMany(p => p.Settings)
- .HasForeignKey(d => d.TenantId)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("REL_SETTING_TENANT_ID");
- */
- }
- );
- }
- }
- }
|