Synchronization code

This commit is contained in:
sunkaixuan
2023-10-11 12:14:56 +08:00
parent cd55d7f63f
commit 65323f0b44
3 changed files with 52 additions and 1 deletions

View File

@@ -109,6 +109,9 @@ namespace SqlSugar
#region Double
case "float":
result = "Convert.ToSingle";
break;
case "double":
result = "Convert.ToDouble";
break;
#endregion

View File

@@ -452,7 +452,7 @@ namespace SqlSugar
return item.DbColumnName;
}
}
private string GetPropertyTypeName(DbColumnInfo item)
protected virtual string GetPropertyTypeName(DbColumnInfo item)
{
string result = item.PropertyType != null ? item.PropertyType.Name : this.Context.Ado.DbBind.GetPropertyTypeName(item.DataType);
if (result != "string" && result != "byte[]" && result != "object" && item.IsNullable)
@@ -483,6 +483,30 @@ namespace SqlSugar
{
return "string";
}
if (item.DataType == "tinyint unsigned")
{
return "short";
}
if (item.DataType == "smallint unsigned")
{
return "ushort";
}
if (item.DataType == "bigint unsigned")
{
return "ulong";
}
if (item.DataType == "int unsigned")
{
return "uint";
}
if (item.DataType == "MediumInt")
{
return "int";
}
if (item.DataType == "MediumInt unsigned")
{
return "uint";
}
return result;
}
private string GetPropertyTypeConvert(DbColumnInfo item)

View File

@@ -7,5 +7,29 @@ namespace SqlSugar
{
public class MySqlDbFirst : DbFirstProvider
{
protected override string GetPropertyTypeName(DbColumnInfo item)
{
if (item.DataType == "tinyint" && item.Length == 1&&this.Context.CurrentConnectionConfig.ConnectionString.ToLower().Contains("treattinyasboolea")==false)
{
item.DataType = "bit";
item.DefaultValue = "true";
return "bool";
}
if (item.DataType == "mediumint")
{
item.DataType = "int";
return "int";
}
if (item.DataType == "mediumint unsigned")
{
item.DataType = "mediumint unsigned";
return "uint";
}
if (item.DataType == "double unsigned")
{
return "double";
}
return base.GetPropertyTypeName(item);
}
}
}