@@ -99,13 +99,12 @@ public Dictionary<string, object[]> CompareState(TEntity newdata)
99
99
if ( string . IsNullOrEmpty ( key ) ) throw new Exception ( DbContextErrorStrings . Incomparable_PrimaryKey_NotSet ( Orm . GetEntityString ( EntityType , newdata ) ) ) ;
100
100
if ( _states . TryGetValue ( key , out var oldState ) == false || oldState == null ) throw new Exception ( $ "不可对比,数据未被跟踪:{ Orm . GetEntityString ( EntityType , newdata ) } ") ;
101
101
AggregateRootTrackingChangeInfo tracking = new AggregateRootTrackingChangeInfo ( ) ;
102
- AggregateRootUtils . CompareEntityValue ( _boundaryName , Orm , EntityType , oldState , newdata , null , tracking ) ;
103
- return new Dictionary < string , object [ ] >
104
- {
105
- [ "Insert" ] = tracking . InsertLog . Select ( a => new object [ ] { a . Item1 , a . Item2 } ) . ToArray ( ) ,
106
- [ "Delete" ] = tracking . DeleteLog . Select ( a => new object [ ] { a . Item1 , a . Item2 } ) . ToArray ( ) ,
107
- [ "Update" ] = tracking . UpdateLog . Select ( a => new object [ ] { a . Item1 , a . Item2 , a . Item3 , a . Item4 } ) . ToArray ( ) ,
108
- } ;
102
+ AggregateRootUtils . CompareEntityValue ( _boundaryName , Orm , EntityType , oldState . Value , newdata , null , tracking ) ;
103
+ var result = new Dictionary < string , object [ ] > ( ) ;
104
+ if ( tracking . InsertLog . Any ( ) ) result . Add ( "Insert" , tracking . InsertLog . Select ( a => new object [ ] { a . Item1 , a . Item2 } ) . ToArray ( ) ) ;
105
+ if ( tracking . DeleteLog . Any ( ) ) result . Add ( "Delete" , tracking . DeleteLog . Select ( a => new object [ ] { a . Item1 , a . Item2 } ) . ToArray ( ) ) ;
106
+ if ( tracking . UpdateLog . Any ( ) ) result . Add ( "Update" , tracking . UpdateLog . Select ( a => new object [ ] { a . Item1 , a . Item2 , a . Item3 , a . Item4 } ) . ToArray ( ) ) ;
107
+ return result ;
109
108
}
110
109
public void FlushState ( )
111
110
{
0 commit comments