FieldWorkClient/Provider/SqlSugarConfig.cs

37 lines
1010 B
C#
Raw Normal View History

2025-04-02 09:30:13 +08:00
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()
2025-04-02 09:30:13 +08:00
{
return new SqlSugarClient(new ConnectionConfig()
2025-04-02 09:30:13 +08:00
{
ConnectionString = @"DataSource=minio.db", // 数据库路径
2025-04-02 09:30:13 +08:00
DbType = DbType.Sqlite, // 数据库类型
IsAutoCloseConnection = true, // 自动释放
InitKeyType = InitKeyType.Attribute // 从实体特性中读取主键信息
},
db =>
{
// 配置AOP
db.Aop.OnLogExecuting = (sql, pars) =>
{
//Console.WriteLine(sql); // 输出SQL
Console.WriteLine(UtilMethods.GetSqlString(DbType.SqlServer, sql, pars));
2025-04-02 09:30:13 +08:00
};
});
}
2025-04-02 09:30:13 +08:00
}
}