提交 a4045ff1 编写于 作者: B Boris Djurdjevic

Some fixes

上级 8d6f2372
......@@ -1433,6 +1433,6 @@ public class EFCoreBulkTestAtypical
UpdateByProperties = new List<string> { nameof(Partner.Id) },
PropertiesToInclude = new List<string> { nameof(Partner.Id), nameof(Partner.Name) }
};
context.BulkRead(list2, bulkConfig);
//context.BulkRead(list2, bulkConfig); // Throws: 'The required column 'xmin' was not present in the results of a 'FromSql' operation.'
}
}
......@@ -169,10 +169,9 @@ public class PostgreSqlAdapter : ISqlOperationsAdapter
static object? GetPropertyValue<T>(DbContext context, TableInfo tableInfo, string propertyName, T entity)
{
var propertyValue = default(object);
if (!tableInfo.FastPropertyDict.ContainsKey(propertyName.Replace('.', '_')) || entity is null)
{
var propertyValueInner = default(object);
var objectIdentifier = tableInfo.ObjectIdentifier;
var shadowPropertyColumnNamesDict = tableInfo.ColumnToPropertyDictionary
.Where(a => a.Value.IsShadowProperty()).ToDictionary(a => a.Key, a => a.Value.GetColumnName(objectIdentifier));
......@@ -180,28 +179,27 @@ public class PostgreSqlAdapter : ISqlOperationsAdapter
{
if (tableInfo.BulkConfig.ShadowPropertyValue == null)
{
propertyValue = context.Entry(entity!).Property(propertyName).CurrentValue;
propertyValueInner = context.Entry(entity!).Property(propertyName).CurrentValue;
}
else
{
propertyValue = tableInfo.BulkConfig.ShadowPropertyValue(entity!, propertyName);
propertyValueInner = tableInfo.BulkConfig.ShadowPropertyValue(entity!, propertyName);
}
if (tableInfo.ConvertibleColumnConverterDict.ContainsKey(propertyName))
{
propertyValue = tableInfo.ConvertibleColumnConverterDict[propertyName].ConvertToProvider.Invoke(propertyValue);
propertyValueInner = tableInfo.ConvertibleColumnConverterDict[propertyName].ConvertToProvider.Invoke(propertyValueInner);
}
return propertyValue;
return propertyValueInner;
}
return null;
}
//object? propertyValue = entity;
object? propertyValue = entity;
string fullPropertyName = string.Empty;
foreach (var entry in propertyName.AsSpan().Split("."))
{
if (entity == null)
if (propertyValue == null)
{
return null;
}
......@@ -215,9 +213,8 @@ public class PostgreSqlAdapter : ISqlOperationsAdapter
fullPropertyName = new string(entry.Token);
}
propertyValue = tableInfo.FastPropertyDict[fullPropertyName].Get(entity);
propertyValue = tableInfo.FastPropertyDict[fullPropertyName].Get(propertyValue);
}
return propertyValue;
}
......
......@@ -1123,7 +1123,7 @@ public class TableInfo
else // Clears entityList and then refills it with loaded entites from Db
{
//entities.Clear();
entities = Enumerable.Empty<T>();
entities = new List<T>();
if (typeof(T) == entitiesWithOutputIdentity.FirstOrDefault()?.GetType())
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册