Browse Source

Synchronization code

SqlSugar5
sunkaixuan 2 years ago
parent
commit
6aa268f305
  1. 2
      Src/Asp.Net/SqlSugar/Abstract/CodeFirstProvider/CodeFirstProvider.cs
  2. 28
      Src/Asp.Net/SqlSugar/Realization/MySql/CodeFirst/MySqlCodeFirst.cs

2
Src/Asp.Net/SqlSugar/Abstract/CodeFirstProvider/CodeFirstProvider.cs

@ -597,7 +597,7 @@ namespace SqlSugar
return properyTypeName.ToLower() != dataType.ToLower();
}
}
private static string GetType(string name)
protected string GetType(string name)
{
if (name.IsContainsIn("UInt32", "UInt16", "UInt64"))
{

28
Src/Asp.Net/SqlSugar/Realization/MySql/CodeFirst/MySqlCodeFirst.cs

@ -81,5 +81,33 @@ namespace SqlSugar
{
return EntityColumnToDbColumn(entity,dbTableName,item);
}
protected override void GetDbType(EntityColumnInfo item, Type propertyType, DbColumnInfo result)
{
if (!string.IsNullOrEmpty(item.DataType))
{
result.DataType = item.DataType;
}
else if (propertyType.IsEnum())
{
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(item.Length > 9 ? UtilConstants.LongType.Name : UtilConstants.IntType.Name);
}
else
{
var name = GetType(propertyType.Name);
if (name == "Boolean")
{
result.DataType = "tinyint";
result.Length = 1;
result.Scale = 0;
result.DecimalDigits = 0;
}
else
{
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(name);
}
}
}
}
}

Loading…
Cancel
Save