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.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/FreeSqlUnit.cs

37 lines
1.0 KiB
C#

1 year ago
using Mesnac.Action.ChemicalWeighing.Sys;
using Mesnac.Codd.Session;
using System;
using System.Collections.Generic;
1 year ago
using System.Diagnostics;
1 year ago
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mesnac.Action.ChemicalWeighing.FreeDb
{
public class FreeSqlUnit
{
1 year ago
public static IFreeSql Instance => freeSql.Value;
static Lazy<IFreeSql> freeSql = new Lazy<IFreeSql>(() =>
1 year ago
{
1 year ago
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
return new FreeSql.FreeSqlBuilder()
.UseMonitorCommand(cmd => Trace.WriteLine($"Sql{cmd.CommandText}"))//监听SQL语句,Trace在输出选项卡中查看
.UseConnectionString(FreeSql.DataType.SqlServer, dbHelper.DbSession.ConnectionString)
.UseAutoSyncStructure(false) //自动同步实体结构到数据库FreeSql不会扫描程序集只有CRUD时才会生成表。
.Build();
1 year ago
});
1 year ago
}
}
1 year ago