PaperFillConfiguration.cs 1.5 KB

123456789101112131415161718192021222324252627
  1. using Domain.Entities.Paper;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Paper;
  5. public sealed class PaperFillConfiguration : IEntityTypeConfiguration<PaperFill>
  6. {
  7. public void Configure(EntityTypeBuilder<PaperFill> builder)
  8. {
  9. builder.HasOne(x => x.Order).WithMany().HasForeignKey(x => x.OrderID).OnDelete(DeleteBehavior.Cascade);
  10. builder.HasIndex(x => x.OrderID).IsUnique();
  11. builder.ToTable(nameof(PaperFill), t => t.HasComment("모의투자 체결 결과 (주문당 1건, 멱등)"));
  12. builder.HasKey(x => x.ID);
  13. builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK");
  14. builder.Property(x => x.OrderID).IsRequired().HasComment("주문 ID");
  15. builder.Property(x => x.Price).HasPrecision(18, 0).IsRequired().HasComment("체결가");
  16. builder.Property(x => x.Quantity).IsRequired().HasComment("수량");
  17. builder.Property(x => x.Fee).HasPrecision(18, 0).IsRequired().HasComment("수수료");
  18. builder.Property(x => x.Tax).HasPrecision(18, 0).IsRequired().HasComment("거래세");
  19. builder.Property(x => x.Amount).HasPrecision(18, 0).IsRequired().HasComment("체결 총액");
  20. builder.Property(x => x.RealizedPnL).HasPrecision(18, 0).HasComment("매도 확정 손익");
  21. builder.Property(x => x.PriceDate).IsRequired().HasComment("체결가 기준일");
  22. builder.Property(x => x.FilledAt).IsRequired();
  23. }
  24. }