init commit
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user