GlobalVar.cs
975 Bytes
using FreeSql;
using FreeSql.SqlServer;
using System.Configuration;
using System.Data.SqlClient;
namespace HHECS.DAQHandle
{
internal static class GlobalVar
{
private static readonly string connectionString = ConfigurationManager.ConnectionStrings["Default"].ConnectionString;
public static IFreeSql FreeSql => new FreeSqlBuilder()
//.UseConnectionString(DataType.SqlServer, connectionString)
.UseConnectionFactory(DataType.SqlServer, () => new SqlConnection(connectionString), typeof(SqlServerProvider<>))
//监听SQL语句
//.UseMonitorCommand(cmd =>
//{
// if (cmd.CommandText.ToLower().Contains("delete"))
// Console.WriteLine($"Sql:{cmd.CommandText}");
//})
.UseAutoSyncStructure(false) //自动同步实体结构到数据库,FreeSql不会扫描程序集,只有CRUD时才会生成表。
.Build();
}
}