FieldWorkClient/Provider/SqlSugarConfig.cs

35 lines
942 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=E:\数据上传转存\sqlite\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
};
});
}
2025-04-02 09:30:13 +08:00
}
}