Files
number_zj/20220330_Vote/Ewide.RoadFlow/Entity/Extend/rf_dbconnection.cs
2022-03-30 17:54:33 +08:00

56 lines
1.6 KiB
C#

using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RoadFlow.Model
{
public partial class rf_dbconnection
{
[SugarColumn(IsIgnore = true)]
public SqlSugar.DbType DbType
{
get
{
SqlSugar.DbType dbType = SqlSugar.DbType.MySql;
switch (this.ConnType.ToLower())
{
case "sqlserver":
dbType = SqlSugar.DbType.SqlServer;
break;
case "mysql":
dbType = SqlSugar.DbType.MySql;
break;
case "oracle":
dbType = SqlSugar.DbType.Oracle;
break;
case "postgresql":
dbType = SqlSugar.DbType.PostgreSQL;
break;
}
return dbType;
}
}
public SqlSugarProvider GetConn(SqlSugarClient db)
{
SqlSugarProvider conn = null;
if(db.IsAnyConnection(this.Id))
conn = db.GetConnection(this.Id);
if (conn == null)
{
db.AddConnection(new ConnectionConfig
{
DbType = this.DbType,
ConnectionString = this.ConnString,
ConfigId = this.Id,
IsAutoCloseConnection = true
});
conn = db.GetConnection(this.Id);
}
return conn;
}
}
}