AssetManager.API/AssetManager.Data/SqlSugarConfig.cs
2026-02-24 19:25:28 +08:00

28 lines
822 B
C#

using SqlSugar;
namespace AssetManager.Data;
public class SqlSugarConfig
{
public static ISqlSugarClient GetSqlSugarClient()
{
return new SqlSugarScope(new ConnectionConfig()
{
ConnectionString = "server=localhost;Database=assetmanager;Uid=root;Pwd=your_password;CharSet=utf8mb4;",
DbType = DbType.MySql,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute,
ConfigureExternalServices = new ConfigureExternalServices
{
EntityService = (property, column) =>
{
if (property.PropertyType == typeof(DateTime))
{
column.DataType = "datetime(3)";
}
}
}
});
}
}