CustomerDm.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Quadarax.Application.QLiberace.Common.Entities.Base.DaoMapper;
  2. using Microsoft.EntityFrameworkCore;
  3. using Quadarax.Application.QLiberace.Base;
  4. namespace Quadarax.Application.QLiberace.Customer.Entities.DaoMapper
  5. {
  6. public class CustomerDm: TrackedTenantDm<Customer>
  7. {
  8. public override void Map(ModelBuilder builder)
  9. {
  10. if (builder == null) throw new ArgumentNullException(nameof(builder));
  11. base.Map(builder);
  12. builder.Entity<Customer>(entity =>
  13. {
  14. entity.ToTable(Constants.Modules.Customer.TblCustomer, Constants.Modules.Customer.Schema);
  15. // indexes
  16. entity.HasIndex(e => e.Code, "IDX_CUSTOMER_CODE")
  17. .IsUnique();
  18. // columns
  19. entity.Property(e => e.Code).IsRequired()
  20. .HasMaxLength(20)
  21. .HasComment("Customer code. Main key to search.");
  22. entity.Property(e => e.Name).IsRequired()
  23. .HasMaxLength(100)
  24. .HasComment("Customer head name. For identification usage.");
  25. entity.Property(e => e.TaxCountryCode).IsRequired()
  26. .HasMaxLength(5)
  27. .HasComment("Tax country region code");
  28. entity.Property(e => e.TaxNumber)
  29. .HasMaxLength(20)
  30. .HasComment("Customer tax number (business identifier)");
  31. entity.Property(e => e.VatIncluded).IsRequired()
  32. .HasDefaultValueSql("((1))")
  33. .HasComment("Flag if VAT calculation is allowed");
  34. entity.Property(e => e.VatNumber)
  35. .HasMaxLength(20)
  36. .HasComment("Customer VAT number (VAT identification)");
  37. }
  38. );
  39. }
  40. }
  41. }