using Mesnac.Codd.Session;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mesnac.Action.ChemicalWeighing.DBHelper
{
///
/// FreeORM
///
public class FreeHelper
{
public static IFreeSql Instance => freeSql.Value;
static Lazy freeSql = new Lazy(() =>
{
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();
});
}
}