using System; using System.Data.Common; using System.Data.Entity; using System.Data.Entity.ModelConfiguration.Configuration; using System.Data.Entity.ModelConfiguration.Conventions; using System.Web.UI.WebControls; using ShwasherSys.Authorization.Roles; using ShwasherSys.Authorization.Users; using ShwasherSys.BaseSysInfo; using IwbZero; using ShwasherSys.BasicInfo; using ShwasherSys.BasicInfo.OutFactory; using ShwasherSys.CompanyInfo; using ShwasherSys.CustomerInfo; using ShwasherSys.Inspection; using ShwasherSys.Invoice; using ShwasherSys.NotificationInfo; using ShwasherSys.Order; using ShwasherSys.OrderSendInfo; using ShwasherSys.PackageInfo; using ShwasherSys.ProductionOrderInfo; using ShwasherSys.ProductInfo; using ShwasherSys.ProductStoreInfo; using ShwasherSys.ReturnGoods; using ShwasherSys.RmStore; using ShwasherSys.ScrapStore; using ShwasherSys.SemiProductStoreInfo; namespace ShwasherSys.EntityFramework { public class ShwasherDbContext : IwbDbContext { //TODO: Define an IDbSet for each Entity... public IDbSet AppGuids { get; set; } public IDbSet AuditLogs { get; set; } public IDbSet Functions { get; set; } public IDbSet Settings { get; set; } public IDbSet SysStates { get; set; } public IDbSet SysAttachFiles { get; set; } public IDbSet BusinessLogs { get; set; } #region New public IDbSet EmployeeInfo { get; set; } public IDbSet ViewEmployeeInfo { get; set; } public IDbSet EmployeeWorkPerformanceInfo { get; set; } public IDbSet DisqualifiedProductInfo { get; set; } public IDbSet CustomerDisabledProductInfo { get; set; } public IDbSet ProductionOrderLogInfo { get; set; } public IDbSet LicenseDocumentInfo { get; set; } public IDbSet LicenseTypeInfo { get; set; } public IDbSet FixedAssetInfo { get; set; } public IDbSet MoldInfo { get; set; } public IDbSet DeviceMgInfo { get; set; } public IDbSet MaintenanceRecordsInfo { get; set; } public IDbSet MaintenanceMemberInfo { get; set; } public IDbSet QualityIssueLabelInfo { get; set; } public IDbSet ScrapTypeInfo { get; set; } public IDbSet FixedAssetTypeInfo { get; set; } public IDbSet CustomerInvoiceAddressInfo { get; set; } public IDbSet ProductInspectReportInfo { get; set; } #endregion #region ShwasherSys public IDbSet OrderHeaders { get; set; } public IDbSet OrderItems { get; set; } public IDbSet SysHelps { get; set; } public IDbSet Department { get; set; } public IDbSet Dutys { get; set; } public IDbSet StoreHouses { get; set; } public IDbSet StoreHouseLocations { get; set; } public IDbSet Regions { get; set; } public IDbSet Factories { get; set; } public IDbSet OutFactory { get; set; } public IDbSet BulletinInfos { get; set; } public IDbSet Customers { get; set; } public IDbSet CustomerDefaultProducts { get; set; } public IDbSet CustomerSends { get; set; } public IDbSet Products { get; set; } public IDbSet Standards { get; set; } public IDbSet ShortMessages { get; set; } public IDbSet ShortMsgDetails { get; set; } public IDbSet ViewOrderItems { get; set; } public IDbSet ViewOrderSends { get; set; } public IDbSet ViewOrderSendBills { get; set; } public IDbSet SemiProducts { get; set; } public IDbSet ProductionOrders { get; set; } public IDbSet BackUpCurrentSemiStoreHouses { get; set; } public IDbSet CurrentSemiStoreHouses { get; set; } public IDbSet SemiEnterStores { get; set; } public IDbSet SemiOutStores { get; set; } public IDbSet SemiProductStores { get; set; } public IDbSet ProductInspectInfos { get; set; } public IDbSet PtoductInspectReports { get; set; } public IDbSet TemplateInfos { get; set; } public IDbSet PackageApply { get; set; } public IDbSet FinshedEnterStores { get; set; } public IDbSet ProductOutStores { get; set; } public IDbSet CurrentProductStoreHouses { get; set; } public IDbSet OrderSends { get; set; } public IDbSet OrderSendBills { get; set; } public IDbSet OrderStickBills { get; set; } public IDbSet ViewCurrentSemiStoreHouses { get; set; } public IDbSet ViewSemiEnterStores { get; set; } public IDbSet ViewSemiOutStores { get; set; } public IDbSet ViewCustomerSticks { get; set; } public IDbSet OrderUnits { get; set; } public IDbSet ViewOrderSendStickBills { get; set; } public IDbSet ViewQueryCurrentProductNums { get; set; } public IDbSet ViewBookedProductNums { get; set; } public IDbSet ViewCanProductStores { get; set; } public IDbSet ViewProductEnterStores { get; set; } public IDbSet ViewProductOutStores { get; set; } public IDbSet ViewCurrentProductStoreHouses { get; set; } public IDbSet ViewEnterOutProductStores { get; set; } public IDbSet ViewEnterOutLogCus { get; set; } public IDbSet ViewCurrentStoreTotals { get; set; } public IDbSet ViewPackageApply { get; set; } public IDbSet Currency { get; set; } public IDbSet CurrencyExchangeRate { get; set; } public IDbSet ViewStickBill { get; set; } public IDbSet OrderSendExceed { get; set; } public IDbSet StatementBill { get; set; } public IDbSet RmProducts { get; set; } public IDbSet RmEnterStores { get; set; } public IDbSet RmOutStores { get; set; } public IDbSet CurrentRmStoreHouses { get; set; } public IDbSet ViewRmEnterStores { get; set; } public IDbSet ViewRmOutStores { get; set; } public IDbSet ViewCurrentRmStoreHouse { get; set; } public IDbSet ExpressLogistics { get; set; } public IDbSet ExpressProviderMapper { get; set; } public IDbSet ExpressServiceProviders { get; set; } public IDbSet InventoryCheck { get; set; } public IDbSet InventoryCheckRecord { get; set; } public IDbSet ViewInventoryCheckRecordProduct { get; set; } public IDbSet ViewInventoryCheckRecordSemi { get; set; } public IDbSet ViewEnterOutSemiProductStore { get; set; } public IDbSet ViewCurrentSemiStoreTotal { get; set; } public IDbSet ScrapEnterStores { get; set; } public IDbSet ViewScrapEnterStore { get; set; } public IDbSet ReturnGoodOrders { get; set; } public IDbSet ViewStatementBill { get; set; } #endregion #region 产品属性改造 public IDbSet ProductProperty { get; set; } public IDbSet ProductMappers { get; set; } #endregion #region 订单生产环节 public IDbSet OrderProduction { get; set; } #endregion #region 不合格处理 public IDbSet ViewDisqualifiedReturns { get; set; } public IDbSet ViewDisqualifiedProductions { get; set; } #endregion #region 2023 public IDbSet ScheduleOrderSend { get; set; } public IDbSet ScheduleOrderSendView { get; set; } public IDbSet StandardCatalog { get; set; } public IDbSet StandardDetail { get; set; } #endregion #region 2024 public IDbSet MoldProductionRecord { get; set; } //添加订单审核后锁定库存的记录 预先冻结库存 public IDbSet OrderBookStore { get; set; } #endregion #region 2025 public IDbSet WxUser { get; set; } public IDbSet OutSourcingMissStore { get; set; } public IDbSet ViewOutSourcingMiss { get; set; } #endregion //Example: //public virtual IDbSet Users { get; set; } /* NOTE: * Setting "Default" to base class helps us when working migration commands on Package Manager Console. * But it may cause problems when working Migrate.exe of EF. If you will apply migrations on command line, do not * pass connection string name to base classes. ABP works either way. */ public ShwasherDbContext() : base("Default") { } /* NOTE: * This constructor is used by ABP to pass connection string defined in IwbYueDataModule.PreInitialize. * Notice that, actually you will not directly create an instance of IwbYueDbContext since ABP automatically handles it. */ public ShwasherDbContext(string nameOrConnectionString) : base(nameOrConnectionString) { } //This constructor is used in tests public ShwasherDbContext(DbConnection existingConnection) : base(existingConnection, false) { } public ShwasherDbContext(DbConnection existingConnection, bool contextOwnsConnection) : base(existingConnection, contextOwnsConnection) { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Add(new DecimalPrecisionAttributeConvention()); base.OnModelCreating(modelBuilder); //modelBuilder.Conventions.Add(new DecimalPropertyConvention(18,3)); modelBuilder.Entity().Property(t => t.Id) .HasColumnName("OrderItemId"); modelBuilder.Entity().Property(t => t.Quantity) .HasPrecision(18, 3); modelBuilder.Entity().Property(t => t.Id) .HasColumnName("OrderNo"); modelBuilder.Entity().Property(t => t.Id) .HasColumnName("HelpId"); modelBuilder.Entity().Property(t => t.Id) .HasColumnName("DepartmentID"); modelBuilder.Entity().Property(t => t.Id) .HasColumnName("DutyID"); modelBuilder.Entity().Property(t => t.Id) .HasColumnName("StoreHouseID"); modelBuilder.Entity().Property(t => t.Id) .HasColumnName("FactoryID"); modelBuilder.Entity().Property(t => t.Id) .HasColumnName("OutFactoryId"); modelBuilder.Entity().Property(t => t.Id) .HasColumnName("RegionID"); modelBuilder.Entity().Property(t => t.Id) .HasColumnName("BulletinInfoId"); //BulletinInfoId CustomerId modelBuilder.Entity().Property(t => t.Id) .HasColumnName("CustomerId"); modelBuilder.Entity().Property(t => t.Id) .HasColumnName("CustomerSendId"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("ProductNo"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("StandardId"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("MsgID"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("DetailID"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("OrderItemId"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("SemiProductNo"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("OrderSendId"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("OrderSendBillNo"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("OrderStickBillNo"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("OrderSendId"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("OrderSendBillNo"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("OrderUnitId"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("OrderSendId"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("OrderSendId"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("ProductNo"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("ProductNo"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("ProductNo"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("ProductNo"); modelBuilder.Entity().Property(t => t.Id).HasColumnName("OrderStickBillNo"); modelBuilder.Entity().Property(t => t.Quantity) .HasPrecision(18, 3); } } /// /// 用于modelBuilder全局设置自定义精度属性 /// public class DecimalPrecisionAttributeConvention : PrimitivePropertyAttributeConfigurationConvention { public override void Apply(ConventionPrimitivePropertyConfiguration configuration, DecimalPrecisionAttribute attribute) { if (attribute.Precision < 1 || attribute.Precision > 38) { throw new InvalidOperationException("Precision must be between 1 and 38."); } if (attribute.Scale > attribute.Precision) { throw new InvalidOperationException("Scale must be between 0 and the Precision value."); } configuration.HasPrecision(attribute.Precision, attribute.Scale); } } }