28 lines
822 B
C#
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)";
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|