2024年3月24日发(作者:司空仙仪)
IsAutoCloseConnection = true, //默认false
InitKeyType = Table
});
var key=d().ToString().Replace("-", "");
if (!_nsKey(key))
{
_(key,new SqlClient(client));
_ = key;
return client;
}
throw new Exception("创建SqlSugarClient失败");
}
public static SqlClient GetInstance()
{
var id= _;
if (OrEmpty(id)||!_nsKey(id))
return new SqlClient(CreatInstance());
return _cache[id];
}
public static void Release()
{
try
{
var id = GetId();
if (!_nsKey(id))
return;
Remove(id);
}
catch (Exception e)
{
throw e;
}
}
private static bool Remove(string id)
{
if (!_nsKey(id)) return false;
SqlClient client;
int index = 0;
bool result = false;
while (!(result = _ove(id, out client)))
{
index++;
(20);
if (index > 3) break;
}
return result;
}
private static string GetId()
{
var id = _;
if (OrEmpty(id))
{
throw new Exception("内部错误: SqlSugarClient已丢失.");
}
return id;
}
public static void BeginTran()
{
var instance=GetInstance();
//开启事务
if (!nTran)
{
ran();
nTran = true;
}
}
public static void CommitTran()
{
var id = GetId();
if (!_nsKey(id))
2024年3月24日发(作者:司空仙仪)
IsAutoCloseConnection = true, //默认false
InitKeyType = Table
});
var key=d().ToString().Replace("-", "");
if (!_nsKey(key))
{
_(key,new SqlClient(client));
_ = key;
return client;
}
throw new Exception("创建SqlSugarClient失败");
}
public static SqlClient GetInstance()
{
var id= _;
if (OrEmpty(id)||!_nsKey(id))
return new SqlClient(CreatInstance());
return _cache[id];
}
public static void Release()
{
try
{
var id = GetId();
if (!_nsKey(id))
return;
Remove(id);
}
catch (Exception e)
{
throw e;
}
}
private static bool Remove(string id)
{
if (!_nsKey(id)) return false;
SqlClient client;
int index = 0;
bool result = false;
while (!(result = _ove(id, out client)))
{
index++;
(20);
if (index > 3) break;
}
return result;
}
private static string GetId()
{
var id = _;
if (OrEmpty(id))
{
throw new Exception("内部错误: SqlSugarClient已丢失.");
}
return id;
}
public static void BeginTran()
{
var instance=GetInstance();
//开启事务
if (!nTran)
{
ran();
nTran = true;
}
}
public static void CommitTran()
{
var id = GetId();
if (!_nsKey(id))