Synchronization code

This commit is contained in:
sunkaixuan
2024-02-14 14:46:41 +08:00
parent 67dc12e3a7
commit 29e9965f79

View File

@@ -1870,6 +1870,8 @@ namespace SqlSugar
else
{
result = this.Context.Utilities.DataReaderToList<TResult>(dataReader);
if (StaticConfig.EnableAot)
ResetNavigationPropertiesForAot(result);
}
}
else
@@ -1914,6 +1916,8 @@ namespace SqlSugar
else
{
result = await this.Context.Utilities.DataReaderToListAsync<TResult>(dataReader);
if (StaticConfig.EnableAot)
ResetNavigationPropertiesForAot(result);
}
}
else
@@ -1923,6 +1927,24 @@ namespace SqlSugar
SetContextModel(result, entityType);
return result;
}
private void ResetNavigationPropertiesForAot<TResult>(List<TResult> result)
{
if (StaticConfig.EnableAot)
{
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo<TResult>();
var navColumnList = entityInfo.Columns.Where(it => it.Navigat != null);
if (navColumnList.Any())
{
foreach (var item in result)
{
foreach (var columnInfo in navColumnList)
{
columnInfo.PropertyInfo.SetValue(item, null);
}
}
}
}
}
protected void _InQueryable(Expression expression, KeyValuePair<string, List<SugarParameter>> sqlObj)
{
QueryBuilder.CheckExpression(expression, "In");