Skip to content

Commit 8512a1b

Browse files
author
zzzprojects
committed
Merge
Merge
1 parent ccdfe2b commit 8512a1b

File tree

6 files changed

+34
-17
lines changed

6 files changed

+34
-17
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,12 @@ public int Execute<T>(IQueryable<T> query) where T : class
186186
return 0;
187187
}
188188

189+
// GET model and info
190+
#if EF5 || EF6
191+
var dbContext = query.GetDbContext();
192+
189193
#if EF6
190-
if (query.IsInMemoryEffortQueryContext())
194+
if (dbContext.IsInMemoryEffortQueryContext())
191195
{
192196
var context = query.GetDbContext();
193197

@@ -198,9 +202,6 @@ public int Execute<T>(IQueryable<T> query) where T : class
198202
}
199203
#endif
200204

201-
// GET model and info
202-
#if EF5 || EF6
203-
var dbContext = query.GetDbContext();
204205
var model = dbContext.GetModel();
205206
var entity = model.Entity<T>();
206207
var keys = entity.Info.Key.PropertyRefs;

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using System.Linq;
1313
using System.Linq.Expressions;
1414
using System.Text.RegularExpressions;
15-
using System.Reflection;
1615
#if EF5
1716
using System.Data.Objects;
1817
using System.Data.SqlClient;
@@ -22,6 +21,7 @@
2221
using System.Data.Entity.Core.Objects;
2322
using System.Data.Entity.Infrastructure.Interception;
2423
using System.Data.SqlClient;
24+
using System.Reflection;
2525
using Z.EntityFramework.Plus.Internal.Core.SchemaObjectModel;
2626

2727
#elif EFCORE
@@ -185,8 +185,12 @@ public int Execute<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory)
185185
{
186186
return 0;
187187
}
188+
189+
#if EF5 || EF6
190+
var dbContext = query.GetDbContext();
191+
188192
#if EF6
189-
if (query.IsInMemoryEffortQueryContext())
193+
if (dbContext.IsInMemoryEffortQueryContext())
190194
{
191195
var context = query.GetDbContext();
192196

@@ -214,12 +218,9 @@ public int Execute<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory)
214218
}
215219
#endif
216220

217-
#if EF5 || EF6
218-
219221
var objectQuery = query.GetObjectQuery();
220222

221223
// GET model and info
222-
var dbContext = query.GetDbContext();
223224
var model = dbContext.GetModel();
224225
var entity = model.Entity<T>();
225226

@@ -272,7 +273,6 @@ public int Execute<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory)
272273
innerObjectQuery.Context.Connection.Close();
273274
}
274275
}
275-
276276
#elif EFCORE
277277
if (BatchUpdateManager.InMemoryDbContextFactory != null && query.IsInMemoryQueryContext())
278278
{
@@ -343,7 +343,7 @@ public int Execute<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory)
343343
}
344344
}
345345
#endif
346-
}
346+
}
347347

348348
#if EF5 || EF6
349349
/// <summary>Creates a command to execute the batch operation.</summary>
@@ -1159,7 +1159,7 @@ public Dictionary<string, object> ResolveUpdateFromQueryDictValues<T>(Expression
11591159
{
11601160
var lambda = Expression.Lambda(m, null);
11611161
var value = lambda.Compile().DynamicInvoke();
1162-
var c = Expression.Constant(value);
1162+
var c = Expression.Constant(value, m.Type);
11631163
return c;
11641164
}
11651165

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#if FULL || BATCH_DELETE || BATCH_UPDATE
2+
#if EF6
3+
using System.Data.Entity;
4+
5+
namespace Z.EntityFramework.Plus
6+
{
7+
internal static partial class InternalExtensions
8+
{
9+
public static bool IsInMemoryEffortQueryContext(this DbContext @this)
10+
{
11+
return @this.Database.Connection.GetType().FullName == "Effort.Provider.EffortConnection";
12+
}
13+
}
14+
}
15+
16+
#endif
17+
#endif

src/shared/Z.EF.Plus._Core.Shared/EF6/IQueryable`/IsInMemoryEffortQueryContext.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-

1+
#if FULL || BATCH_DELETE || BATCH_UPDATE
22
#if EF6
3-
using System;
4-
using System.Data.Entity;
53
using System.Linq;
6-
using System.Reflection;
74

85
namespace Z.EntityFramework.Plus
96
{
@@ -17,3 +14,4 @@ public static bool IsInMemoryEffortQueryContext<T>(this IQueryable<T> q)
1714
}
1815

1916
#endif
17+
#endif

src/shared/Z.EF.Plus._Core.Shared/Z.EF.Plus._Core.Shared.projitems

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<Compile Include="$(MSBuildThisFileDirectory)EF5_EF6\ObjectContext\CreateStoreCommand.cs" />
3939
<Compile Include="$(MSBuildThisFileDirectory)EF5_EF6\ObjectContext\GetEntitySet.cs" />
4040
<Compile Include="$(MSBuildThisFileDirectory)EF5_EF6\Object\Object.GetObjectQuery.cs" />
41+
<Compile Include="$(MSBuildThisFileDirectory)EF6\DbContext\IsInMemoryEffortQueryContext.cs" />
4142
<Compile Include="$(MSBuildThisFileDirectory)EF6\IQueryable`\IsInMemoryEffortQueryContext.cs" />
4243
<Compile Include="$(MSBuildThisFileDirectory)EF6\ObjectContext\GetDbContext.cs" />
4344
<Compile Include="$(MSBuildThisFileDirectory)EF6\ObjectContext\GetInterceptionContext.cs" />

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.6.17
1+
v1.6.18

0 commit comments

Comments
 (0)