You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
786 B
C#

8 months ago
using System.Diagnostics;
namespace WorkerSynReport.Plc;
public class FreeSqlUnit
{
public static IFreeSql Instance => freeSql.Value;
private static Lazy<IFreeSql> freeSql = new Lazy<IFreeSql>(() =>
{
string ConnectionString = "Data Source=172.18.4.130;Initial Catalog=CWSSHG;user=sa;password=123456;Encrypt=false;";
return new FreeSql.FreeSqlBuilder()
.UseMonitorCommand(cmd => Trace.WriteLine($"Sql{cmd.CommandText}"))//监听SQL语句,Trace在输出选项卡中查看
.UseConnectionString(FreeSql.DataType.SqlServer, ConnectionString)
.UseAutoSyncStructure(false) //自动同步实体结构到数据库FreeSql不会扫描程序集只有CRUD时才会生成表。
.Build();
});
}