using System;
|
using System.Collections.Generic;
|
using System.Reflection;
|
using System.Text;
|
using SqlSugar;
|
|
namespace WMS.Entity.Context
|
{
|
public class DataContext
|
{
|
public static readonly SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig()
|
{
|
ConnectionString = BaseDbConfig.ConnectionString,
|
//ConnectionString = "server=.;database=WMS_JC08;uid=sa;pwd=sa; Integrated Security=True",
|
//ConnectionString = "Data Source=.;Initial Catalog=WMS_JC08;Integrated Security=True",
|
DbType = DbType.SqlServer, //数据库类型
|
IsAutoCloseConnection = true, //自动释放
|
InitKeyType = InitKeyType.Attribute //根据实体类取发现主键
|
});
|
|
public DataContext()
|
{
|
//Db = new SqlSugarScope(new ConnectionConfig()
|
//{
|
// //ConnectionString = "server=.;database=WMS_V01;uid=sa;pwd=sa",
|
// ConnectionString = "Data Source=.;Initial Catalog=WMS_V01;Integrated Security=True",
|
// DbType = DbType.SqlServer, //数据库类型
|
// IsAutoCloseConnection = true, //自动释放
|
// InitKeyType = InitKeyType.Attribute //根据实体类取发现主键
|
//});
|
}
|
|
//第一次创建数据库实体时用到、后面注释就行
|
public void Init()
|
{
|
////入库
|
//var luJing = "E:\\WMSJC09Gitee\\Wms_09\\WMS.Entity\\BllAsnEntity";
|
//var yinYong = "WMS.Entity.BllAsnEntity";
|
//Db.DbFirst.IsCreateAttribute().Where("BllArrivalNotice").CreateClassFile(luJing, yinYong);
|
//Db.DbFirst.IsCreateAttribute().Where("BllArrivalNoticeDetail").CreateClassFile(luJing, yinYong);
|
//Db.DbFirst.IsCreateAttribute().Where("BllPalletBind").CreateClassFile(luJing, yinYong);
|
//Db.DbFirst.IsCreateAttribute().Where("BllBoxInfo").CreateClassFile(luJing, yinYong);
|
//Db.DbFirst.IsCreateAttribute().Where("BllPalletUnbind").CreateClassFile(luJing, yinYong);
|
////库存
|
//var luJing1 = "E:\\WMSJC09Gitee\\Wms_09\\WMS.Entity\\DataEntity";
|
//var yinYong1 = "WMS.Entity.DataEntity";
|
//Db.DbFirst.IsCreateAttribute().Where("DataStockDetail").CreateClassFile(luJing1, yinYong1);
|
//Db.DbFirst.IsCreateAttribute().Where("DataBoxInfo").CreateClassFile(luJing1, yinYong1);
|
////出库
|
//var luJing2 = "E:\\WMSJC09Gitee\\Wms_09\\WMS.Entity\\BllSoEntity";
|
//var yinYong2 = "WMS.Entity.BllSoEntity";
|
//Db.DbFirst.IsCreateAttribute().Where("BllExportAllot").CreateClassFile(luJing2, yinYong2);
|
//Db.DbFirst.IsCreateAttribute().Where("BllCompleteDetail").CreateClassFile(luJing2, yinYong2);
|
//Db.DbFirst.IsCreateAttribute().Where("BLLWaveMage").CreateClassFile(luJing2, yinYong2);
|
////日志
|
//var luJing3 = "E:\\WMSJC09Gitee\\Wms_09\\WMS.Entity\\LogEntity";
|
//var yinYong3 = "WMS.Entity.LogEntity";
|
//Db.DbFirst.IsCreateAttribute().Where("LogOperationASN").CreateClassFile(luJing3, yinYong3);
|
//Db.DbFirst.IsCreateAttribute().Where("LogOperationSO").CreateClassFile(luJing3, yinYong3);
|
//Db.DbFirst.IsCreateAttribute().Where("LogOperationCR").CreateClassFile(luJing3, yinYong3);
|
//Db.DbFirst.IsCreateAttribute().Where("LogTask").CreateClassFile(luJing3, yinYong3);
|
////移
|
//var luJing4 = "E:\\WMSJC09Gitee\\Wms_09\\WMS.Entity\\BllMoveEntity";
|
//var yinYong4 = "WMS.Entity.BllMoveEntity";
|
//Db.DbFirst.IsCreateAttribute().Where("BllPalletMove").CreateClassFile(luJing4, yinYong4);
|
////盘、
|
//var luJing5 = "E:\\WMSJC09Gitee\\Wms_09\\WMS.Entity\\BllCheckEntity";
|
//var yinYong5 = "WMS.Entity.BllCheckEntity";
|
//Db.DbFirst.IsCreateAttribute().Where("BllStockCheck").CreateClassFile(luJing5, yinYong5);
|
//Db.DbFirst.IsCreateAttribute().Where("BllStockCheckDetail").CreateClassFile(luJing5, yinYong5);
|
//Db.DbFirst.IsCreateAttribute().Where("BllStockCheckLog").CreateClassFile(luJing5, yinYong5);
|
////移
|
//var luJing6 = "E:\\WMSJC09Gitee\\Wms_09\\WMS.Entity\\BllQualityEntity";
|
//var yinYong6 = "WMS.Entity.BllQualityEntity";
|
//Db.DbFirst.IsCreateAttribute().Where("BllQualityInspect").CreateClassFile(luJing6, yinYong6);
|
|
|
//Db.DbMaintenance.CreateDatabase();
|
//Assembly assembly = Assembly.Load("AoLian.Model");
|
|
//foreach (var item in assembly.GetTypes())
|
//{
|
// if (item.Name == "AoLianContext") continue;
|
// if (item.Name != "BaseEntity")
|
// {
|
// Db.CodeFirst.InitTables(item);
|
// }
|
//}
|
|
}
|
}
|
public class BaseDbConfig
|
{
|
/// <summary>
|
/// 数据库连接字符串
|
/// </summary>
|
public static string ConnectionString { get; set; }
|
|
}
|
}
|