GlobalVar.cs 840 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<>))
            // .UseMonitorCommand(cmd => Console.WriteLine($"Sql:{cmd.CommandText}"))//监听SQL语句
            .UseAutoSyncStructure(false) //自动同步实体结构到数据库,FreeSql不会扫描程序集,只有CRUD时才会生成表。
            .Build();
    }
}