Skip to content

Commit a1da413

Browse files
Update source
Update source
1 parent 296a3cd commit a1da413

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

src/shared/Z.EF.Plus.Audit.Shared/Audit/AuditEntityAdded.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ public static void AuditEntityAdded(AuditEntry auditEntry, ObjectStateEntry obje
7070
// Complex Type
7171
AuditEntityAdded(auditEntry, objectStateEntry, valueRecord, string.Concat(prefix, name, "."));
7272
}
73-
else if (objectStateEntry.EntitySet.ElementType.KeyMembers.Any(x => x.Name == name) || auditEntry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(auditEntry.Entry, string.Concat(prefix, name)))
74-
{
75-
var auditEntryProperty = auditEntry.Parent.Configuration.AuditEntryPropertyFactory != null ?
73+
else if (objectStateEntry.EntitySet.ElementType.KeyMembers.Any(x => x.Name == name) ||
74+
(auditEntry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(auditEntry.Entry, string.Concat(prefix, name))
75+
&& !auditEntry.Parent.CurrentOrDefaultConfiguration.IgnorePropertyAdded))
76+
{
77+
var auditEntryProperty = auditEntry.Parent.Configuration.AuditEntryPropertyFactory != null ?
7678
auditEntry.Parent.Configuration.AuditEntryPropertyFactory(new AuditEntryPropertyArgs(auditEntry, objectStateEntry, string.Concat(prefix, name), null, value)) :
7779
new AuditEntryProperty();
7880

@@ -102,7 +104,8 @@ public static void AuditEntityAdded(AuditEntry entry, EntityEntry objectStateEnt
102104
{
103105
var property = objectStateEntry.Property(propertyEntry.Name);
104106

105-
if (property.Metadata.IsKey() || entry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(entry.Entry, propertyEntry.Name))
107+
if (property.Metadata.IsKey() || (entry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(entry.Entry, propertyEntry.Name)
108+
&& !entry.Parent.CurrentOrDefaultConfiguration.IgnorePropertyAdded))
106109
{
107110
var auditEntryProperty = entry.Parent.Configuration.AuditEntryPropertyFactory != null ?
108111
entry.Parent.Configuration.AuditEntryPropertyFactory(new AuditEntryPropertyArgs(entry, objectStateEntry, propertyEntry.Name, null, property.CurrentValue)) :
@@ -126,8 +129,8 @@ public static void AuditEntityAdded(AuditEntry entry, EntityEntry objectStateEnt
126129
}
127130
#endif
128131

129-
// https://stackoverflow.com/questions/2490244/default-value-of-a-type-at-runtime
130-
internal static object DefaultValue(Type type)
132+
// https://stackoverflow.com/questions/2490244/default-value-of-a-type-at-runtime
133+
internal static object DefaultValue(Type type)
131134
{
132135
if (type.IsValueType)
133136
return Activator.CreateInstance(type);

src/shared/Z.EF.Plus.Audit.Shared/AuditConfiguration.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,13 @@ public AuditConfiguration()
111111
/// <value>true if unchanged property of a modified entity are audited, false if not.</value>
112112
public bool IgnorePropertyUnchanged { get; set; }
113113

114-
/// <summary>Gets or sets a dictionary indicating if an entity type or a property name is audited.</summary>
115-
/// <value>A dictionary indicating if an entity type or a property name is audited.</value>
116-
public ConcurrentDictionary<string, bool> IsAuditedDictionary { get; set; }
114+
/// <summary>Gets or sets a value indicating whether the property for entity with Added state are audited.</summary>
115+
/// <value>true if the property for entity with Added state are audited, false if not.</value>
116+
public bool IgnorePropertyAdded { get; set; }
117+
118+
/// <summary>Gets or sets a dictionary indicating if an entity type or a property name is audited.</summary>
119+
/// <value>A dictionary indicating if an entity type or a property name is audited.</value>
120+
public ConcurrentDictionary<string, bool> IsAuditedDictionary { get; set; }
117121

118122
/// <summary>Gets or sets a list of predicates to check if the modified entity is soft added.</summary>
119123
/// <value>A list of predicates to check if the modified entity is soft added.</value>
@@ -142,12 +146,12 @@ public AuditConfiguration()
142146
/// Gets or sets a value indicating whether null value should be used in the Audit instead of DBNull.Value
143147
/// </summary>
144148
/// <value>The value indicating whether null value should be used in the Audit instead of DBNull.Value</value>
145-
public bool UseNullForDBNullValue { get; set; }
149+
public bool UseNullForDBNullValue { get; set; }
146150
#endif
147151

148-
/// <summary>Makes a deep copy of this object.</summary>
149-
/// <returns>A copy of this object.</returns>
150-
public AuditConfiguration Clone()
152+
/// <summary>Makes a deep copy of this object.</summary>
153+
/// <returns>A copy of this object.</returns>
154+
public AuditConfiguration Clone()
151155
{
152156
var audit = new AuditConfiguration
153157
{
@@ -173,6 +177,7 @@ public AuditConfiguration Clone()
173177
SoftDeletedPredicates = new List<Func<object, bool>>(SoftDeletedPredicates),
174178
ExcludeRelationshipIfOneExcluded = ExcludeRelationshipIfOneExcluded,
175179
UseUtcDateTime = UseUtcDateTime,
180+
IgnorePropertyAdded = IgnorePropertyAdded,
176181
#if EF5 || EF6
177182
UseNullForDBNullValue = UseNullForDBNullValue
178183
#endif

src/shared/Z.EF.Plus.BatchDelete.Shared/BatchDelete.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,8 @@ public DbCommand CreateCommand(IQueryable query, IEntityType entity)
833833
}
834834

835835
primaryKeys = propertyAndColumnName.Count > 1 ?
836-
string.Join(Environment.NewLine + "AND ", propertyAndColumnName.Select(x => string.Concat("\"", x.Item2, "\" = B.\"", x.Item1, "\""))):
837-
string.Join(Environment.NewLine + "AND ", propertyAndColumnName.Select(x => string.Concat("\"", x.Item2, "\" = B.\"", x.Item2, "\"")));
836+
string.Join(Environment.NewLine + "AND ", propertyAndColumnName.Select(x => string.Concat(tableName + ".\"", x.Item2, "\" = B.\"", x.Item1, "\""))):
837+
string.Join(Environment.NewLine + "AND ", propertyAndColumnName.Select(x => string.Concat(tableName + ".\"", x.Item2, "\" = B.\"", x.Item2, "\"")));
838838
}
839839
else if (isOracle || isDevOracle)
840840
{

0 commit comments

Comments
 (0)