RepositoryContext.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using System;
  2. using System.Collections.Generic;
  3. using Entities.Models;
  4. using Microsoft.EntityFrameworkCore;
  5. using Microsoft.EntityFrameworkCore.Metadata;
  6. namespace Entities
  7. {
  8. public partial class RepositoryContext : DbContext
  9. {
  10. public RepositoryContext()
  11. {
  12. }
  13. public RepositoryContext(DbContextOptions<RepositoryContext> options)
  14. : base(options)
  15. {
  16. }
  17. public virtual DbSet<BankAccountBalance> BankAccountBalances { get; set; } = null!;
  18. public virtual DbSet<BankOperation> BankOperations { get; set; } = null!;
  19. public virtual DbSet<Transaction> Transactions { get; set; } = null!;
  20. protected override void OnModelCreating(ModelBuilder modelBuilder)
  21. {
  22. modelBuilder.Entity<BankAccountBalance>(entity => {
  23. entity.ToTable("SK_BankAccountBalances", "SEPTEM");
  24. entity.HasIndex(e => e.BankAccountId, "IX_SK_BankAccountBalances_BankAccountId");
  25. entity.Property(e => e.Id).ValueGeneratedNever();
  26. entity.Property(e => e.Amount).HasPrecision(18, 3);
  27. entity.Property(e => e.BalanceType).HasMaxLength(50);
  28. });
  29. modelBuilder.Entity<BankOperation>(entity => {
  30. entity.ToTable("SK_BankOperations", "SEPTEM");
  31. entity.HasIndex(e => e.BankAccountId, "IX_SK_BankOperations_BankAccountId");
  32. entity.HasIndex(e => e.CashOperationTypeId, "IX_SK_BankOperations_CashOperationTypeId");
  33. entity.HasIndex(e => e.CustomerId, "IX_SK_BankOperations_CustomerId");
  34. entity.HasIndex(e => e.OperationPurposeId, "IX_SK_BankOperations_OperationPurposeId");
  35. entity.Property(e => e.Id).ValueGeneratedNever();
  36. entity.Property(e => e.AdvanceAmount).HasPrecision(18, 2);
  37. entity.Property(e => e.BalanceAmount).HasPrecision(18, 2);
  38. entity.Property(e => e.Code).HasMaxLength(50);
  39. entity.Property(e => e.CreatedDate).HasColumnType("timestamp without time zone");
  40. entity.Property(e => e.DocDate).HasColumnType("timestamp without time zone");
  41. entity.Property(e => e.IncomeAmount).HasPrecision(18, 2);
  42. entity.Property(e => e.ModifiedDate).HasColumnType("timestamp without time zone");
  43. entity.Property(e => e.Note).HasMaxLength(5000);
  44. entity.Property(e => e.OutcomeAmount).HasPrecision(18, 2);
  45. entity.Property(e => e.Purpose).HasMaxLength(150);
  46. entity.Property(e => e.Status).HasMaxLength(50);
  47. entity.Property(e => e.IsChanged).HasDefaultValue(false);
  48. entity.Property(e => e.OrderId);
  49. });
  50. modelBuilder.Entity<Transaction>(entity => {
  51. entity.ToTable("SK_Transactions", "SEPTEM");
  52. entity.HasIndex(e => e.BankOperationId, "IX_SK_Transactions_BankOperationId");
  53. entity.Property(e => e.Id).ValueGeneratedNever();
  54. entity.Property(e => e.BalanceAmount).HasPrecision(18, 2);
  55. entity.Property(e => e.IncomeAmount).HasPrecision(18, 2);
  56. entity.Property(e => e.OutcomeAmount).HasPrecision(18, 2);
  57. entity.Property(e => e.ModifiedDate).HasColumnType("timestamp without time zone");
  58. entity.Property(e => e.CreateDate).HasColumnType("timestamp without time zone");
  59. entity.Property(e => e.OperationCreateDate).HasColumnType("timestamp without time zone");
  60. entity.HasIndex(e => e.BankAccountId, "IX_SK_Transactions_BankAccountId");
  61. entity.HasIndex(e => e.BusinessId);
  62. entity.Property(e => e.OperationOrderId);
  63. entity.HasOne(d => d.BankOperation)
  64. .WithMany(p => p.SkTransactions)
  65. .HasForeignKey(d => d.BankOperationId)
  66. .HasForeignKey(d => d.BankAccountId);
  67. });
  68. OnModelCreatingPartial(modelBuilder);
  69. }
  70. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  71. }
  72. }