Skip to content

Commit f29d283

Browse files
author
zzzprojects
committed
Fix BatchUpdate, BatchDelete Issue with Database First
Fix BatchUpdate, BatchDelete Issue with Database First
1 parent 06e52f7 commit f29d283

File tree

35 files changed

+222
-34
lines changed

35 files changed

+222
-34
lines changed

src/Z.EntityFramework.Plus.EF5.NET40/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
[assembly: AssemblyCulture("")]
1919
[assembly: ComVisible(false)]
2020
[assembly: Guid("e4c2af73-caeb-4429-bcb6-0a359484e064")]
21-
[assembly: AssemblyVersion("1.2.1")]
22-
[assembly: AssemblyFileVersion("1.2.1")]
21+
[assembly: AssemblyVersion("1.2.4")]
22+
[assembly: AssemblyFileVersion("1.2.4")]

src/Z.EntityFramework.Plus.EF5.NET40/Z.EntityFramework.Plus.EF5.NET40.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
<Compile Include="_Internal\EF5\DbContext.SaveChangesAsync.cs" />
147147
<Compile Include="_Internal\EF5\IDbSet`\DbContext.AddRange.cs" />
148148
<Compile Include="_Internal\EF5\IDbSet`\DbContext.RemoveRange.cs" />
149+
<Compile Include="_Internal\EF5_EF6\Database\GetEntityConnection.cs" />
149150
<Compile Include="_Internal\EF5_EF6\DbContext\DbContext.GetObjectContext.cs" />
150151
<Compile Include="_Internal\EF5_EF6\EntityConnection\GetDbTransaction.cs" />
151152
<Compile Include="_Internal\EF5_EF6\EntityConnection\GetEntityTransaction.cs" />

src/Z.EntityFramework.Plus.EF5.NET40/_Internal/DynamicAnonymousType/DynamicAnonymousType.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal static class DynamicAnonymousType
2020
{
2121

2222
private static readonly AssemblyName AssemblyName = new AssemblyName { Name = "<>f__AnonymousType" };
23-
#if NETCORE50
23+
#if NETSTANDARD1_3
2424
private static readonly ModuleBuilder ModuleBuilder = System.Reflection.Emit.AssemblyBuilder.DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess.Run).DefineDynamicModule(AssemblyName.Name);
2525
#else
2626
private static readonly ModuleBuilder ModuleBuilder = Thread.GetDomain().DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess.Run).DefineDynamicModule(AssemblyName.Name);
@@ -112,7 +112,7 @@ public static Type GetDynamicType(List<Tuple<string, Type>> fields)
112112
foreach (var field in fields)
113113
typeBuilder.DefineField(field.Item1, field.Item2, FieldAttributes.Public);
114114

115-
#if NETCORE50
115+
#if NETSTANDARD1_3
116116
BuiltTypes[typeKey] = new Tuple<string, Type>(typeName, typeBuilder.CreateTypeInfo().AsType());
117117
#else
118118
BuiltTypes[typeKey] = new Tuple<string, Type>(typeName, typeBuilder.CreateType());

src/Z.EntityFramework.Plus.EF5.NET40/_Internal/EF/DbContext/DbContext.GetDbSetProperties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal static List<PropertyInfo> GetDbSetProperties(this DbContext context)
3636
#if EF5 || EF6
3737
var isDbSet = setType.IsGenericType && (typeof (IDbSet<>).IsAssignableFrom(setType.GetGenericTypeDefinition()) || setType.GetInterface(typeof (IDbSet<>).FullName) != null);
3838
#elif EFCORE
39-
#if NETCORE50
39+
#if NETSTANDARD1_3
4040
var isDbSet = setType.GetType().IsConstructedGenericType && (typeof (DbSet<>).IsAssignableFrom(setType.GetGenericTypeDefinition()));
4141
#else
4242
var isDbSet = setType.IsGenericType && (typeof(DbSet<>).IsAssignableFrom(setType.GetGenericTypeDefinition()));

src/Z.EntityFramework.Plus.EF5.NET40/_Internal/EF/IQueryable`/IQueryable.Order.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#if FULL
99
using System.Linq;
1010
using System.Linq.Expressions;
11-
#if NETCORE50
11+
#if NETSTANDARD1_3
1212
using System.Reflection;
1313
#endif
1414
namespace Z.EntityFramework.Plus

src/Z.EntityFramework.Plus.EF5.NET40/_Internal/EF/Type/Type.GetDbSetElementType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static Type GetDbSetElementType(this Type type)
4444
return null;
4545
#elif EFCORE
4646

47-
#if NETCORE50
47+
#if NETSTANDARD1_3
4848
return type.GetTypeInfo().GenericTypeArguments[0];
4949
#else
5050
return type.GetGenericArguments()[0];
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 FULL || BATCHDELETE || BATCHUPDATE
9+
#if EF5 || EF6
10+
11+
#if EF5
12+
using System.Data.Common;
13+
using System.Data.Entity;
14+
using System.Data.Entity.Infrastructure;
15+
using System.Data.EntityClient;
16+
using System.Data.Objects;
17+
using System.Reflection;
18+
19+
#elif EF6
20+
using System.Data.Common;
21+
using System.Data.Entity;
22+
using System.Data.Entity.Core.EntityClient;
23+
using System.Data.Entity.Core.Objects;
24+
using System.Reflection;
25+
26+
#endif
27+
28+
namespace Z.EntityFramework.Plus
29+
{
30+
internal static partial class InternalExtensions
31+
{
32+
public static EntityConnection GetEntityConnection(this Database @this)
33+
{
34+
object internalContext = @this.GetType().GetField("_internalContext", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(@this);
35+
36+
MethodInfo getObjectContext = internalContext.GetType().GetMethod("GetObjectContextWithoutDatabaseInitialization", BindingFlags.Public | BindingFlags.Instance);
37+
var objectContext = (ObjectContext)getObjectContext.Invoke(internalContext, null);
38+
DbConnection entityConnection = objectContext.Connection;
39+
40+
return (EntityConnection)entityConnection;
41+
}
42+
}
43+
}
44+
45+
#endif
46+
#endif

src/Z.EntityFramework.Plus.EF5.NET40/_Internal/EF5_EF6/IQueryable/IQueryable.SelectByName.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using System.Linq;
1212
using System.Linq.Expressions;
1313

14-
#if NETCORE50
14+
#if NETSTANDARD1_3
1515
using System.Reflection;
1616
#endif
1717

src/Z.EntityFramework.Plus.EF5.NET40/_Internal/EFCore/CreateEntity/CreateEntityDataReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public override int RecordsAffected
5757
get { return OriginalDataReader.RecordsAffected; }
5858
}
5959

60-
//#if !NETCORE50
60+
//#if !NETSTANDARD1_3
6161
// public override void Close()
6262
// {
6363
// // DO NOT close reader

src/Z.EntityFramework.Plus.EF5.NET40/_Internal/Model/Model/Model.GetModelName.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal static partial class Model
2020
/// <returns>The model name.</returns>
2121
internal static string GetModelName(this DbContext @this)
2222
{
23-
var connectionString = @this.Database.Connection.ConnectionString;
23+
var connectionString = @this.Database.GetEntityConnection().ConnectionString;
2424
var end = connectionString.IndexOf(".msl") - 1;
2525

2626
if (end <= -1)

0 commit comments

Comments
 (0)