C# Program.cs文件
static void Main()
{
List? ioclist = null;
string jsonFilePath = "Conn.json";
using (StreamReader sr = new StreamReader(jsonFilePath))
{
string json = sr.ReadToEnd();
ioclist = JsonConvert.DeserializeObject<List<IocConfig>>(json);
}
SugarIocServices.AddSqlSugar(ioclist);
SugarIocServices.ConfigurationSugar(db =>
{
db.Aop.OnLogExecuting = (sql, p) =>
{
Console.WriteLine(sql);
};
});
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
Json
[
{
"ConfigId": "IMS",
"DbType": "1",
"ConnectionString": "data source=192.168.1.1,1433;database=dbname;user id=sa;pwd=passwd;connect timeout=30",
"IsAutoCloseConnection": "true"
},
{
"ConfigId": "MES",
"DbType": "1",
"ConnectionString": "data source=192.168.1.1,1433;database=dbname;user id=sa;pwd=passwd;connect timeout=30",
"IsAutoCloseConnection": "true"
}
]