fix: orm实体与表字段不一致时可能导致批量操作失败

This commit is contained in:
Diego
2025-10-23 18:56:34 +08:00
parent 0e44bc67cd
commit 0c31cfcbc5
3 changed files with 16 additions and 5 deletions

View File

@@ -694,8 +694,12 @@ namespace ThingsGateway.SqlSugar
var enumerator = table.GetEnumerator();
while (enumerator.MoveNext())
{
var cur = enumerator.Current;
yield return cur.Value.Item2[rowIndex];
var kvp = enumerator.Current;
var list = kvp.Value.Item2;
if (list != null && rowIndex < list.Count)
yield return list[rowIndex];
else
yield return new DataInfos { ColumnName = kvp.Key, Value = null };
}
}

View File

@@ -201,6 +201,7 @@ namespace ThingsGateway.SqlSugar
{
foreach (var column in columns)
{
if (column.IsIgnore)
{
continue;
@@ -210,6 +211,12 @@ namespace ThingsGateway.SqlSugar
{
name = column.PropertyName;
}
if (!results.TryGetValue(name, out var tuple) || tuple.Item2 == null)
{
// 某些列可能不在 DataTable 中(例如数据库多了列)
continue;
}
var value = ValueConverter(column, GetValue(item, column));
if (column.SqlParameterDbType != null && column.SqlParameterDbType is Type && UtilMethods.HasInterface((Type)column.SqlParameterDbType, typeof(ISugarDataConverter)))
{

View File

@@ -1,9 +1,9 @@
<Project>
<PropertyGroup>
<PluginVersion>10.12.7</PluginVersion>
<ProPluginVersion>10.12.7</ProPluginVersion>
<DefaultVersion>10.12.7</DefaultVersion>
<PluginVersion>10.12.8</PluginVersion>
<ProPluginVersion>10.12.8</ProPluginVersion>
<DefaultVersion>10.12.8</DefaultVersion>
<AuthenticationVersion>10.11.6</AuthenticationVersion>
<SourceGeneratorVersion>10.11.6</SourceGeneratorVersion>
<NET8Version>8.0.21</NET8Version>