Synchronization code

This commit is contained in:
sunkaixuan 2024-07-16 13:55:08 +08:00
parent 518dd51fa4
commit 957be334b4

View File

@ -280,7 +280,12 @@ namespace SqlSugar
foreach (DataColumn item in dataTable.Columns)
{
var isPrimaryKey = whereColumns.Any(it => it.EqualCase(item.ColumnName));
builder.CreateProperty(item.ColumnName,typeof(Nullable<>).MakeGenericType(item.DataType), new SugarColumn()
var propertyType = item.DataType;
if (!propertyType.IsClass()&& propertyType!=typeof(string) && propertyType != typeof(byte[]))
{
propertyType=typeof(Nullable<>).MakeGenericType(UtilMethods.GetUnderType(item.DataType));
}
builder.CreateProperty(item.ColumnName, propertyType, new SugarColumn()
{
IsPrimaryKey = isPrimaryKey,
IsIdentity=isIdentity&& isPrimaryKey,