Synchronization code

This commit is contained in:
sunkaixuan 2023-11-17 02:29:51 +08:00
parent 7d930b2c6a
commit f85cfd3600
3 changed files with 26 additions and 2 deletions

View File

@ -103,7 +103,7 @@ namespace SqlSugar
{ {
name = column.PropertyName; name = column.PropertyName;
} }
var value = ValueConverter(column, PropertyCallAdapterProvider<T>.GetInstance(column.PropertyName).InvokeGet(item)); var value = ValueConverter(column, GetValue(item,column));
if (column.SqlParameterDbType != null&& column.SqlParameterDbType is Type && UtilMethods.HasInterface((Type)column.SqlParameterDbType, typeof(ISugarDataConverter))) if (column.SqlParameterDbType != null&& column.SqlParameterDbType is Type && UtilMethods.HasInterface((Type)column.SqlParameterDbType, typeof(ISugarDataConverter)))
{ {
var columnInfo = column; var columnInfo = column;
@ -155,6 +155,18 @@ namespace SqlSugar
return dt; return dt;
} }
private static object GetValue(T item, EntityColumnInfo column)
{
if (StaticConfig.EnableAot)
{
return column.PropertyInfo.GetValue(item);
}
else
{
return PropertyCallAdapterProvider<T>.GetInstance(column.PropertyName).InvokeGet(item);
}
}
private string GetTableName() private string GetTableName()
{ {
if (this.AsName.HasValue()) if (this.AsName.HasValue())

View File

@ -252,7 +252,7 @@ namespace SqlSugar
var isMapping = IsMappingColumns; var isMapping = IsMappingColumns;
var columnInfo = new DbColumnInfo() var columnInfo = new DbColumnInfo()
{ {
Value = PropertyCallAdapterProvider<T>.GetInstance(column.PropertyName).InvokeGet(item), Value = GetValue(item,column),
DbColumnName = column.DbColumnName, DbColumnName = column.DbColumnName,
PropertyName = column.PropertyName, PropertyName = column.PropertyName,
PropertyType = UtilMethods.GetUnderType(column.PropertyInfo), PropertyType = UtilMethods.GetUnderType(column.PropertyInfo),
@ -316,6 +316,17 @@ namespace SqlSugar
} }
} }
} }
private static object GetValue(T item, EntityColumnInfo column)
{
if (StaticConfig.EnableAot)
{
return column.PropertyInfo.GetValue(item, null);
}
else
{
return PropertyCallAdapterProvider<T>.GetInstance(column.PropertyName).InvokeGet(item);
}
}
private string GetDbColumnName(string propertyName) private string GetDbColumnName(string propertyName)
{ {

View File

@ -8,6 +8,7 @@ namespace SqlSugar
{ {
public class StaticConfig public class StaticConfig
{ {
public static bool EnableAot { get; set; }
public static Func<string,string> Encode { get; set; } public static Func<string,string> Encode { get; set; }
public static Func<string,string> Decode{ get; set; } public static Func<string,string> Decode{ get; set; }
public static bool AppContext_ConvertInfinityDateTime { get; set; } public static bool AppContext_ConvertInfinityDateTime { get; set; }