Skip to content

Commit 81aad76

Browse files
author
zzzprojects
committed
Update to v1.0.5
Update to v1.0.5
1 parent f559d2c commit 81aad76

File tree

84 files changed

+1228
-109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1228
-109
lines changed

src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/BatchDelete.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
using System.Data.Entity.Core.Objects;
1919
using Z.EntityFramework.Plus.Internal.Core.SchemaObjectModel;
2020

21-
#elif EF7
21+
#elif EFCORE
2222
using System.Reflection;
2323
using Microsoft.Data.Entity;
2424
using Microsoft.Data.Entity.Metadata;
@@ -155,7 +155,7 @@ public int Execute<T>(IQueryable<T> query) where T : class
155155
innerObjectQuery.Context.Connection.Close();
156156
}
157157
}
158-
#elif EF7
158+
#elif EFCORE
159159
var dbContext = query.GetDbContext();
160160
var entity = dbContext.Model.FindEntityType(typeof (T));
161161
var keys = entity.GetKeys().ToList()[0].Properties;
@@ -250,12 +250,16 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
250250
var parameterCollection = query.Parameters;
251251
foreach (var parameter in parameterCollection)
252252
{
253-
command.Parameters.Add(parameter);
253+
var param = command.CreateParameter();
254+
param.ParameterName = parameter.Name;
255+
param.Value = parameter.Value;
256+
257+
command.Parameters.Add(param);
254258
}
255259

256260
return command;
257261
}
258-
#elif EF7
262+
#elif EFCORE
259263
public DbCommand CreateCommand(IQueryable query, IEntityType entity)
260264
{
261265
var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.FullName == "EntityFramework.MicrosoftSqlServer, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60");
@@ -311,7 +315,11 @@ public DbCommand CreateCommand(IQueryable query, IEntityType entity)
311315
var parameterCollection = relationalCommand.Parameters;
312316
foreach (var parameter in parameterCollection)
313317
{
314-
command.Parameters.Add(parameter);
318+
var param = command.CreateParameter();
319+
param.ParameterName = parameter.Name;
320+
param.Value = parameter.Value;
321+
322+
command.Parameters.Add(param);
315323
}
316324

317325
return command;

src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/DbContext.CreateStoreCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
77

88
#if STANDALONE
9-
#if EF7
9+
#if EFCORE
1010
using System.Data.Common;
1111
using Microsoft.Data.Entity;
1212
using Microsoft.Data.Entity.Infrastructure;

src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.CreateCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
77

88
#if STANDALONE
9-
#if EF7
9+
#if EFCORE
1010
using System.Linq;
1111
using System.Reflection;
1212
using Microsoft.Data.Entity.Query;

src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
77

88
#if STANDALONE
9-
#if EF7
9+
#if EFCORE
1010
using System.Linq;
1111
using System.Reflection;
1212
using Microsoft.Data.Entity;

src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.GetDbContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ internal static DbContext GetDbContext<T>(this IQueryable<T> query)
2727
#if EF5
2828
var provider = query.Provider;
2929
var internalContextProperty = provider.GetType().GetProperty("InternalContext", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
30-
var internalContext = internalContextProperty.GetValue(provider);
30+
var internalContext = internalContextProperty.GetValue(provider, null);
3131

3232
var ownerProperty = internalContext.GetType().GetProperty("Owner", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
33-
var owner = ownerProperty.GetValue(internalContext);
33+
var owner = ownerProperty.GetValue(internalContext, null);
3434
return (DbContext) owner;
3535
#elif EF6
3636
return query.GetObjectQuery().Context.GetDbContext();

src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/BatchUpdate.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
using System.Data.Entity.Core.Objects;
2020
using Z.EntityFramework.Plus.Internal.Core.SchemaObjectModel;
2121

22-
#elif EF7
22+
#elif EFCORE
2323
using System.Reflection;
2424
using Microsoft.Data.Entity;
2525
using Microsoft.Data.Entity.Metadata;
@@ -163,7 +163,7 @@ public int Execute<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory)
163163
innerObjectQuery.Context.Connection.Close();
164164
}
165165
}
166-
#elif EF7
166+
#elif EFCORE
167167
var dbContext = query.GetDbContext();
168168
var entity = dbContext.Model.FindEntityType(typeof (T));
169169

@@ -272,7 +272,11 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
272272
var parameterCollection = query.Parameters;
273273
foreach (var parameter in parameterCollection)
274274
{
275-
command.Parameters.Add(parameter);
275+
var param = command.CreateParameter();
276+
param.ParameterName = parameter.Name;
277+
param.Value = parameter.Value;
278+
279+
command.Parameters.Add(param);
276280
}
277281

278282
for (var i = 0; i < values.Count; i++)
@@ -292,7 +296,7 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
292296

293297
return command;
294298
}
295-
#elif EF7
299+
#elif EFCORE
296300
public DbCommand CreateCommand(IQueryable query, IEntityType entity, List<Tuple<string, object>> values)
297301
{
298302
var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.FullName == "EntityFramework.MicrosoftSqlServer, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60");
@@ -355,7 +359,11 @@ public DbCommand CreateCommand(IQueryable query, IEntityType entity, List<Tuple<
355359
var parameterCollection = relationalCommand.Parameters;
356360
foreach (var parameter in parameterCollection)
357361
{
358-
command.Parameters.Add(parameter);
362+
var param = command.CreateParameter();
363+
param.ParameterName = parameter.Name;
364+
param.Value = parameter.Value;
365+
366+
command.Parameters.Add(param);
359367
}
360368

361369
for (var i = 0; i < values.Count; i++)
@@ -381,14 +389,14 @@ public DbCommand CreateCommand(IQueryable query, IEntityType entity, List<Tuple<
381389

382390
#if EF5 || EF6
383391
internal List<Tuple<string, object>> GetInnerValues<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory, SchemaEntityType<T> entity) where T : class
384-
#elif EF7
392+
#elif EFCORE
385393
public List<Tuple<string, object>> GetInnerValues<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory, IEntityType entity) where T : class
386394
#endif
387395
{
388396
#if EF5 || EF6
389397
// GET mapping
390398
var mapping = entity.Info.EntityTypeMapping.MappingFragment;
391-
#elif EF7
399+
#elif EFCORE
392400
var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.FullName == "EntityFramework.MicrosoftSqlServer, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60");
393401

394402
if (assembly == null)
@@ -415,7 +423,7 @@ public List<Tuple<string, object>> GetInnerValues<T>(IQueryable<T> query, Expres
415423
throw new Exception("The destination column could not be found:" + value.Key);
416424
}
417425
var columnName = column.ColumnName;
418-
#elif EF7
426+
#elif EFCORE
419427

420428
var property = entity.FindProperty(value.Key);
421429
var mappingProperty = sqlServerPropertyMethod.Invoke(null, new[] {property});
@@ -458,7 +466,7 @@ public List<Tuple<string, object>> GetInnerValues<T>(IQueryable<T> query, Expres
458466
// Add the destination name
459467
valueSql = valueSql.Replace("AS [C1]", "");
460468
valueSql = valueSql.Replace("[Extent1]", "B");
461-
#elif EF7
469+
#elif EFCORE
462470
var command = ((IQueryable) result).CreateCommand();
463471
var commandText = command.CommandText;
464472

src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/DbContext.CreateStoreCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
77

88
#if STANDALONE
9-
#if EF7
9+
#if EFCORE
1010
using System.Data.Common;
1111
using Microsoft.Data.Entity;
1212
using Microsoft.Data.Entity.Infrastructure;

src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.CreateCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
77

88
#if STANDALONE
9-
#if EF7
9+
#if EFCORE
1010
using System.Linq;
1111
using System.Reflection;
1212
using Microsoft.Data.Entity.Query;

src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
77

88
#if STANDALONE
9-
#if EF7
9+
#if EFCORE
1010
using System.Linq;
1111
using System.Reflection;
1212
using Microsoft.Data.Entity;

src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.GetDbContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ internal static DbContext GetDbContext<T>(this IQueryable<T> query)
2727
#if EF5
2828
var provider = query.Provider;
2929
var internalContextProperty = provider.GetType().GetProperty("InternalContext", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
30-
var internalContext = internalContextProperty.GetValue(provider);
30+
var internalContext = internalContextProperty.GetValue(provider, null);
3131

3232
var ownerProperty = internalContext.GetType().GetProperty("Owner", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
33-
var owner = ownerProperty.GetValue(internalContext);
33+
var owner = ownerProperty.GetValue(internalContext, null);
3434
return (DbContext) owner;
3535
#elif EF6
3636
return query.GetObjectQuery().Context.GetDbContext();

0 commit comments

Comments
 (0)