|
12 | 12 | using System.Linq; |
13 | 13 | using System.Linq.Expressions; |
14 | 14 | using System.Text.RegularExpressions; |
15 | | -using System.Reflection; |
16 | 15 | #if EF5 |
17 | 16 | using System.Data.Objects; |
18 | 17 | using System.Data.SqlClient; |
|
22 | 21 | using System.Data.Entity.Core.Objects; |
23 | 22 | using System.Data.Entity.Infrastructure.Interception; |
24 | 23 | using System.Data.SqlClient; |
| 24 | +using System.Reflection; |
25 | 25 | using Z.EntityFramework.Plus.Internal.Core.SchemaObjectModel; |
26 | 26 |
|
27 | 27 | #elif EFCORE |
@@ -185,8 +185,12 @@ public int Execute<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory) |
185 | 185 | { |
186 | 186 | return 0; |
187 | 187 | } |
| 188 | + |
| 189 | +#if EF5 || EF6 |
| 190 | + var dbContext = query.GetDbContext(); |
| 191 | + |
188 | 192 | #if EF6 |
189 | | - if (query.IsInMemoryEffortQueryContext()) |
| 193 | + if (dbContext.IsInMemoryEffortQueryContext()) |
190 | 194 | { |
191 | 195 | var context = query.GetDbContext(); |
192 | 196 |
|
@@ -214,12 +218,9 @@ public int Execute<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory) |
214 | 218 | } |
215 | 219 | #endif |
216 | 220 |
|
217 | | -#if EF5 || EF6 |
218 | | - |
219 | 221 | var objectQuery = query.GetObjectQuery(); |
220 | 222 |
|
221 | 223 | // GET model and info |
222 | | - var dbContext = query.GetDbContext(); |
223 | 224 | var model = dbContext.GetModel(); |
224 | 225 | var entity = model.Entity<T>(); |
225 | 226 |
|
@@ -272,7 +273,6 @@ public int Execute<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory) |
272 | 273 | innerObjectQuery.Context.Connection.Close(); |
273 | 274 | } |
274 | 275 | } |
275 | | - |
276 | 276 | #elif EFCORE |
277 | 277 | if (BatchUpdateManager.InMemoryDbContextFactory != null && query.IsInMemoryQueryContext()) |
278 | 278 | { |
@@ -343,7 +343,7 @@ public int Execute<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory) |
343 | 343 | } |
344 | 344 | } |
345 | 345 | #endif |
346 | | - } |
| 346 | + } |
347 | 347 |
|
348 | 348 | #if EF5 || EF6 |
349 | 349 | /// <summary>Creates a command to execute the batch operation.</summary> |
@@ -1159,7 +1159,7 @@ public Dictionary<string, object> ResolveUpdateFromQueryDictValues<T>(Expression |
1159 | 1159 | { |
1160 | 1160 | var lambda = Expression.Lambda(m, null); |
1161 | 1161 | var value = lambda.Compile().DynamicInvoke(); |
1162 | | - var c = Expression.Constant(value); |
| 1162 | + var c = Expression.Constant(value, m.Type); |
1163 | 1163 | return c; |
1164 | 1164 | } |
1165 | 1165 |
|
|
0 commit comments