Files
DMS/Data/DbContext.cs

25 lines
688 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using SqlSugar;
namespace PMSWPF.Data;
public class DbContext
{
private static SqlSugarClient _db;
public static SqlSugarClient GetInstance()
{
if (_db == null)
{
var connectionString = "server=127.0.0.1;port=3306;user=root;password=Pgw15221236646; database=pmswpf;";
_db = new SqlSugarClient(new ConnectionConfig
{
ConnectionString = connectionString,
DbType = DbType.MySql, // 根据实际数据库类型修改如DbType.MySql等
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute
});
}
return _db;
}
}