mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
- 完善 DbContext/UnitOfWork EntityChange 更新对象之前的值;
This commit is contained in:
@ -363,15 +363,16 @@ namespace FreeSql
|
||||
|
||||
if (data?.Count > 0)
|
||||
{
|
||||
|
||||
if (cuig.Length == _table.Columns.Count)
|
||||
return ups.Length == data.Count ? -998 : -997;
|
||||
|
||||
var updateSource = data.Select(a => a.Value).ToArray();
|
||||
var update = this.OrmUpdate(null).SetSource(updateSource).IgnoreColumns(cuig);
|
||||
|
||||
var update = this.OrmUpdate(null).SetSource(data.Select(a => a.Value)).IgnoreColumns(cuig);
|
||||
var affrows = await update.ExecuteAffrowsAsync();
|
||||
_db._entityChangeReport.AddRange(updateSource.Select(a => new DbContext.EntityChangeReport.ChangeInfo { Object = a, Type = DbContext.EntityChangeType.Update }));
|
||||
_db._entityChangeReport.AddRange(data.Select(a => new DbContext.EntityChangeReport.ChangeInfo {
|
||||
Object = a.Value,
|
||||
BeforeObject = _states.TryGetValue(a.Key, out var beforeVal) ? beforeVal.Value : null,
|
||||
Type = DbContext.EntityChangeType.Update
|
||||
}));
|
||||
|
||||
foreach (var newval in data)
|
||||
{
|
||||
|
@ -399,15 +399,17 @@ namespace FreeSql
|
||||
|
||||
if (data?.Count > 0)
|
||||
{
|
||||
|
||||
if (cuig.Length == _table.Columns.Count)
|
||||
return ups.Length == data.Count ? -998 : -997;
|
||||
|
||||
var updateSource = data.Select(a => a.Value).ToArray();
|
||||
var update = this.OrmUpdate(null).SetSource(updateSource).IgnoreColumns(cuig);
|
||||
|
||||
var update = this.OrmUpdate(null).SetSource(data.Select(a => a.Value)).IgnoreColumns(cuig);
|
||||
var affrows = update.ExecuteAffrows();
|
||||
_db._entityChangeReport.AddRange(updateSource.Select(a => new DbContext.EntityChangeReport.ChangeInfo { Object = a, Type = DbContext.EntityChangeType.Update }));
|
||||
_db._entityChangeReport.AddRange(data.Select(a => new DbContext.EntityChangeReport.ChangeInfo
|
||||
{
|
||||
Object = a.Value,
|
||||
BeforeObject = _states.TryGetValue(a.Key, out var beforeVal) ? beforeVal.Value : null,
|
||||
Type = DbContext.EntityChangeType.Update
|
||||
}));
|
||||
|
||||
foreach (var newval in data)
|
||||
{
|
||||
|
Reference in New Issue
Block a user