Skip to content

Commit 4e33907

Browse files
Update source
Update source
1 parent 9e1504c commit 4e33907

File tree

10 files changed

+1159
-654
lines changed

10 files changed

+1159
-654
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit)
2+
// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus
3+
// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues
4+
// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE
5+
// More projects: http://www.zzzprojects.com/
6+
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
7+
8+
#if EF5 || EF6
9+
using System.Data.Entity;
10+
11+
#elif EFCORE
12+
using Microsoft.Data.Entity;
13+
14+
#endif
15+
16+
namespace Z.EntityFramework.Plus
17+
{
18+
public static partial class AuditExtensions
19+
{
20+
/// <summary>Audits and saves all changes made in this context to the underlying database.</summary>
21+
/// <param name="context">The context used to audits and saves all changes made.</param>
22+
/// <param name="audit">The audit to use to add changes made to the context.</param>
23+
/// <returns>The number of objects written to the underlying database.</returns>-
24+
public static int SaveChanges(this DbContext context, Audit audit)
25+
{
26+
audit.PreSaveChanges(context);
27+
var rowAffecteds = context.SaveChanges();
28+
audit.PostSaveChanges();
29+
30+
if (audit.CurrentOrDefaultConfiguration.AutoSavePreAction != null)
31+
{
32+
audit.CurrentOrDefaultConfiguration.AutoSavePreAction(context, audit);
33+
context.SaveChanges();
34+
}
35+
36+
return rowAffecteds;
37+
}
38+
}
39+
}

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,20 @@ public DbCommand CreateCommand(IQueryable query, IEntityType entity)
783783
var param = command.CreateParameter();
784784
param.CopyFrom(relationalParameter, parameter);
785785

786-
command.Parameters.Add(param);
786+
#if !NETSTANDARD1_3
787+
if (isPostgreSQL)
788+
{
789+
Type itemType = param.Value.GetType();
790+
791+
if (itemType.IsEnum)
792+
{
793+
var underlyingType = Enum.GetUnderlyingType(itemType);
794+
param.Value = Convert.ChangeType(param.Value, underlyingType);
795+
}
796+
}
797+
#endif
798+
799+
command.Parameters.Add(param);
787800
}
788801
#else
789802
// ADD Parameter

0 commit comments

Comments
 (0)