Skip to content

Commit 2085914

Browse files
committed
- 调整 Repository 状态管理支持 Ignore 属性(非副本);
1 parent 50f883c commit 2085914

File tree

4 files changed

+114
-14
lines changed

4 files changed

+114
-14
lines changed

Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ void LocalMapEntityValue(Type entityType, object entityFrom, object entityTo, bo
376376

377377
foreach (var prop in table.Properties.Values)
378378
{
379-
if (table.ColumnsByCsIgnore.ContainsKey(prop.Name)) continue;
380-
if (table.ColumnsByCs.ContainsKey(prop.Name))
379+
if (table.ColumnsByCs.ContainsKey(prop.Name) || table.ColumnsByCsIgnore.ContainsKey(prop.Name))
381380
{
381+
//与 EntityUtilExtensions.MapEntityValue 同步修改规则,Ignore 也需要 Map
382382
if (isDict) (entityTo as Dictionary<string, object>)[prop.Name] = table.GetPropertyValue(entityFrom, prop.Name);
383383
else table.SetPropertyValue(entityTo, prop.Name, table.GetPropertyValue(entityFrom, prop.Name));
384384
continue;

Extensions/FreeSql.Extensions.ZeroEntity/ZeroDbContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public SchemaValidationResult ValidateSchema(IEnumerable<TableDescriptor> schema
116116
return SchemaValidationResult.SuccessedResult;
117117
}
118118

119-
public TableInfo GetTableInfo(string name) => _tables.Where(a => a.CsName == name).FirstOrDefault();
119+
public TableInfo GetTableInfo(string name) => _tables.Where(a => string.Compare(a.CsName, name, true) == 0).FirstOrDefault();
120120

121121
public void SyncStructure()
122122
{

FreeSql/Extensions/EntityUtilExtensions.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -330,25 +330,16 @@ public static void MapEntityValue(this IFreeSql orm, Type entityType, object ent
330330
});
331331
foreach (var prop in _table.Properties.Values)
332332
{
333-
if (_table.ColumnsByCsIgnore.ContainsKey(prop.Name)) continue;
334-
if (_table.ColumnsByCs.ContainsKey(prop.Name))
333+
if (_table.ColumnsByCs.ContainsKey(prop.Name) || _table.ColumnsByCsIgnore.ContainsKey(prop.Name))
335334
{
335+
//Ignore 也需要 Map https://github.com/luoyunchong/FreeKit/blob/main/src/IGeekFan.FreeKit.Extras/FreeSql/UnitOfWorkAsyncInterceptor.cs
336336
exps.Add(
337337
Expression.Assign(
338338
Expression.MakeMemberAccess(var2Parm, prop),
339339
Expression.MakeMemberAccess(var1Parm, prop)
340340
)
341341
);
342342
}
343-
344-
//else if (prop.GetSetMethod() != null) {
345-
// exps.Add(
346-
// Expression.Assign(
347-
// Expression.MakeMemberAccess(var2Parm, prop),
348-
// Expression.Default(prop.PropertyType)
349-
// )
350-
// );
351-
//}
352343
}
353344
return Expression.Lambda<Action<object, object>>(Expression.Block(new[] { var1Parm, var2Parm }, exps), new[] { parm1, parm2 }).Compile();
354345
});

FreeSql/FreeSql.xml

Lines changed: 109 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)