55 lines
1.6 KiB
C#
55 lines
1.6 KiB
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;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()
|
|
{
|
|
return new SqlSugarScope(new ConnectionConfig()
|
|
{
|
|
ConnectionString = @"DataSource=minio.db;Journal Mode=WAL;Pooling=true;Max Pool Size=100;",
|
|
DbType = DbType.Sqlite,
|
|
IsAutoCloseConnection = true,
|
|
InitKeyType = InitKeyType.Attribute
|
|
},
|
|
db =>
|
|
{
|
|
db.Aop.OnLogExecuting = (sql, pars) =>
|
|
{
|
|
Console.WriteLine(UtilMethods.GetSqlString(DbType.SqlServer, sql, pars));
|
|
};
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|