@@ -62,14 +62,8 @@ public partial class SaverWithRevision<TBaseRevision, TRevisionId>
62
62
}
63
63
public partial class SaverWithRevision < TBaseRevision , TRevisionId >
64
64
{
65
- private static bool IsTimestampingFieldName ( string name ) => name is nameof ( BasePost . LastSeenAt )
66
- or nameof ( TimestampedEntity . CreatedAt ) or nameof ( TimestampedEntity . UpdatedAt ) ;
67
-
68
65
protected abstract NullFieldsBitMask GetRevisionNullFieldBitMask ( string fieldName ) ;
69
66
70
- protected record ExistingAndNewEntity < TEntity > ( TEntity Existing , TEntity New ) where TEntity : RowVersionedEntity ;
71
- protected record MaybeExistingAndNewEntity < TEntity > ( TEntity ? Existing , TEntity New ) where TEntity : RowVersionedEntity ;
72
-
73
67
protected IEnumerable < ExistingAndNewEntity < TEntity > > SaveNewEntities < TEntity > (
74
68
CrawlerDbContext db ,
75
69
IReadOnlyCollection < MaybeExistingAndNewEntity < TEntity > > maybeEntities )
@@ -103,7 +97,7 @@ on newNavigation.Metadata.Name equals existingNavigation.Metadata.Name
103
97
104
98
// rollback changes that overwrite original values with the default value 0 or null
105
99
// for all fields of TimestampedEntity and BasePost.LastSeenAt
106
- // this will also affect the entity instance which entityInTracking references to it
100
+ // this will also affect the entity instance which existingEntity references to it
107
101
entityEntry . Properties
108
102
. Where ( prop => prop . IsModified && IsTimestampingFieldName ( prop . Metadata . Name ) )
109
103
. ForEach ( prop => prop . IsModified = false ) ;
@@ -141,7 +135,7 @@ protected void SaveExistingEntityRevisions<TEntity, TRevision>(
141
135
pName , p . OriginalValue , p . CurrentValue ) ) )
142
136
{
143
137
p . IsModified = false ;
144
- continue ; // skip following revision check
138
+ continue ; // skip any further revision check
145
139
}
146
140
if ( FieldRevisionIgnorance (
147
141
pName , p . OriginalValue , p . CurrentValue )
@@ -151,7 +145,7 @@ protected void SaveExistingEntityRevisions<TEntity, TRevision>(
151
145
152
146
if ( ! IRevisionProperties . Cache [ typeof ( TRevision ) ] . TryGetValue ( pName , out var revisionProp ) )
153
147
{
154
- object ? ToHexWhenByteArray ( object ? value ) =>
148
+ static object ? ToHexWhenByteArray ( object ? value ) =>
155
149
value is byte [ ] bytes ? bytes . ToHex ( ) : value ;
156
150
logger . LogWarning ( "Updating field {} is not existing in revision table, " +
157
151
"newValue={}, oldValue={}, newObject={}, oldObject={}" ,
@@ -163,7 +157,7 @@ protected void SaveExistingEntityRevisions<TEntity, TRevision>(
163
157
{
164
158
revision ??= revisionFactory ( existingEntity ) ;
165
159
166
- // quote from MSDN https://learn.microsoft.com/en-us/dotnet/api/system.reflection.propertyinfo.setvalue
160
+ // https://learn.microsoft.com/en-us/dotnet/api/system.reflection.propertyinfo.setvalue
167
161
// If the property type of this PropertyInfo object is a value type and value is null
168
162
// the property will be set to the default value for that type.
169
163
// https://stackoverflow.com/questions/3049477/propertyinfo-setvalue-and-nulls
@@ -195,4 +189,10 @@ protected void SaveExistingEntityRevisions<TEntity, TRevision>(
195
189
. GroupBy ( pair => pair . Key , pair => pair . Value )
196
190
. ForEach ( g => AddSplitRevisionsDelegatesKeyByEntityType . Value [ g . Key ] ( db , g ) ) ;
197
191
}
192
+
193
+ private static bool IsTimestampingFieldName ( string name ) => name is nameof ( BasePost . LastSeenAt )
194
+ or nameof ( TimestampedEntity . CreatedAt ) or nameof ( TimestampedEntity . UpdatedAt ) ;
195
+
196
+ protected record ExistingAndNewEntity < TEntity > ( TEntity Existing , TEntity New ) where TEntity : RowVersionedEntity ;
197
+ protected record MaybeExistingAndNewEntity < TEntity > ( TEntity ? Existing , TEntity New ) where TEntity : RowVersionedEntity ;
198
198
}
0 commit comments