FieldWorkClient/Provider/SqlSugarConfig.cs

55 lines
1.7 KiB
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
{
2025-07-15 14:39:21 +08:00
//public static SqlSugarClient GetSqlSugarScope()
//{
// return new SqlSugarClient(new ConnectionConfig()
// {
// ConnectionString = @"DataSource=minio.db;Journal Mode=WAL;", // 数据库路径
// 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));
// };
// });
//}
public static SqlSugarScope GetSqlSugarScope()
2025-04-02 09:30:13 +08:00
{
2025-07-15 14:39:21 +08:00
return new SqlSugarScope(new ConnectionConfig()
2025-04-02 09:30:13 +08:00
{
2025-07-15 14:39:21 +08:00
ConnectionString = @"DataSource=minio.db;Journal Mode=WAL;Pooling=true;Max Pool Size=100;",
DbType = DbType.Sqlite,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute
2025-04-02 09:30:13 +08:00
},
db =>
{
db.Aop.OnLogExecuting = (sql, pars) =>
{
Console.WriteLine(UtilMethods.GetSqlString(DbType.SqlServer, sql, pars));
2025-04-02 09:30:13 +08:00
};
});
}
2025-04-02 09:30:13 +08:00
}
}