添加项目文件。
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace JY.DAL.Repository
|
||||
{
|
||||
public static class DataContext
|
||||
{
|
||||
private static readonly Lazy<SqlSugarScope> _instance = new Lazy<SqlSugarScope>(() =>
|
||||
{
|
||||
string connectionString = ConfigurationManager.ConnectionStrings["CurDB"].ConnectionString;
|
||||
return new SqlSugarScope(new ConnectionConfig
|
||||
{
|
||||
ConnectionString = connectionString,
|
||||
DbType = DbType.SqlServer,
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = InitKeyType.Attribute
|
||||
}, db =>
|
||||
{
|
||||
db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine($"SqlSugar SQL: {sql}");
|
||||
#endif
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
public static SqlSugarScope Instance => _instance.Value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user