mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-17 01:46:18 +08:00
Update CodeFirst
This commit is contained in:
parent
3f39f1c828
commit
7ab606176b
@ -19,7 +19,7 @@ namespace SqlSugar
|
||||
public virtual string GetDbTypeName(string csharpTypeName)
|
||||
{
|
||||
if (csharpTypeName == UtilConstants.ByteArrayType.Name)
|
||||
return "bytea";
|
||||
return "varbinary";
|
||||
if (csharpTypeName.ToLower() == "int32")
|
||||
csharpTypeName = "int";
|
||||
if (csharpTypeName.ToLower() == "int16")
|
||||
|
@ -6,6 +6,26 @@ namespace SqlSugar
|
||||
{
|
||||
public class PostgreSQLDbBind : DbBindProvider
|
||||
{
|
||||
public override string GetDbTypeName(string csharpTypeName)
|
||||
{
|
||||
if (csharpTypeName == UtilConstants.ByteArrayType.Name)
|
||||
return "bytea";
|
||||
if (csharpTypeName.ToLower() == "int32")
|
||||
csharpTypeName = "int";
|
||||
if (csharpTypeName.ToLower() == "int16")
|
||||
csharpTypeName = "short";
|
||||
if (csharpTypeName.ToLower() == "int64")
|
||||
csharpTypeName = "long";
|
||||
if (csharpTypeName.ToLower().IsIn("boolean", "bool"))
|
||||
csharpTypeName = "bool";
|
||||
if (csharpTypeName == "DateTimeOffset")
|
||||
csharpTypeName = "DateTime";
|
||||
var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase)).ToList();
|
||||
if (mappings != null && mappings.Count > 0)
|
||||
return mappings.First().Key;
|
||||
else
|
||||
return "varchar";
|
||||
}
|
||||
public override string GetPropertyTypeName(string dbTypeName)
|
||||
{
|
||||
dbTypeName = dbTypeName.ToLower();
|
||||
|
@ -30,5 +30,26 @@ namespace SqlSugar
|
||||
return table;
|
||||
}
|
||||
}
|
||||
|
||||
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 == "varbinary" && item.Length == 0)
|
||||
{
|
||||
name = "varbinary(max)";
|
||||
}
|
||||
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user