FieldWorkClient/Provider/SqlSugarConfig.cs

35 lines
913 B
C#

using SqlSugar;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hopetry.Provider
{
public class SqlSugarConfig
{
public static SqlSugarClient GetSqlSugarScope()
{
return new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = @"DataSource=minio.db", // 数据库路径
DbType = DbType.Sqlite, // 数据库类型
IsAutoCloseConnection = true, // 自动释放
InitKeyType = InitKeyType.Attribute // 从实体特性中读取主键信息
},
db =>
{
// 配置AOP
db.Aop.OnLogExecuting = (sql, pars) =>
{
Console.WriteLine(sql); // 输出SQL
};
});
}
}
}