123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using SqlSugar;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Uninpho.DBOperation
- {
- /// <summary>
- /// Setting up the database name does not require you to create the database
- /// 设置好数据库名不需要你去手动建库
- /// </summary>
- public class Config
- {
- /// <summary>
- /// 自动化打印,true选择打印
- /// </summary>
- public static bool zdhjc = true;
- public static SqlSugarClient GetPgClient()
- {
- return new SqlSugarClient(new ConnectionConfig()
- {
- DbType = DbType.PostgreSQL,
- ConnectionString = System.Configuration.ConfigurationManager.AppSettings["dbConnection"] as string,
- InitKeyType = InitKeyType.Attribute,
- IsAutoCloseConnection = true,
- AopEvents = new AopEvents
- {
- OnLogExecuting = (sql, p) =>
- {
- if (zdhjc)
- {
- Console.WriteLine(sql);
- Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
- }
- }
- }
- });
- }
- }
- }
|