36 lines
1.4 KiB
C#
36 lines
1.4 KiB
C#
|
|
using Microsoft.EntityFrameworkCore;
|
||
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||
|
|
|
||
|
|
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// استخر کارمزد هفتگی
|
||
|
|
/// </summary>
|
||
|
|
public class WeeklyCommissionPoolConfiguration : IEntityTypeConfiguration<WeeklyCommissionPool>
|
||
|
|
{
|
||
|
|
public void Configure(EntityTypeBuilder<WeeklyCommissionPool> builder)
|
||
|
|
{
|
||
|
|
builder.HasQueryFilter(p => !p.IsDeleted);
|
||
|
|
builder.Ignore(entity => entity.DomainEvents);
|
||
|
|
|
||
|
|
builder.HasKey(entity => entity.Id);
|
||
|
|
builder.Property(entity => entity.Id).UseIdentityColumn();
|
||
|
|
|
||
|
|
builder.Property(entity => entity.WeekNumber).IsRequired().HasMaxLength(20);
|
||
|
|
builder.Property(entity => entity.TotalPoolAmount).IsRequired();
|
||
|
|
builder.Property(entity => entity.TotalBalances).IsRequired();
|
||
|
|
builder.Property(entity => entity.ValuePerBalance).IsRequired();
|
||
|
|
builder.Property(entity => entity.IsCalculated).IsRequired();
|
||
|
|
builder.Property(entity => entity.CalculatedAt).IsRequired(false);
|
||
|
|
|
||
|
|
// Index یونیک برای WeekNumber
|
||
|
|
builder.HasIndex(e => e.WeekNumber)
|
||
|
|
.IsUnique()
|
||
|
|
.HasDatabaseName("IX_WeeklyCommissionPool_WeekNumber");
|
||
|
|
|
||
|
|
// Index برای IsCalculated
|
||
|
|
builder.HasIndex(e => e.IsCalculated)
|
||
|
|
.HasDatabaseName("IX_WeeklyCommissionPool_IsCalculated");
|
||
|
|
}
|
||
|
|
}
|