Skip to content

Commit

Permalink
Update to v1.0.5
Browse files Browse the repository at this point in the history
Update to v1.0.5
  • Loading branch information
zzzprojects committed Apr 3, 2016
1 parent f559d2c commit 81aad76
Show file tree
Hide file tree
Showing 84 changed files with 1,228 additions and 109 deletions.
18 changes: 13 additions & 5 deletions src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/BatchDelete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using System.Data.Entity.Core.Objects;
using Z.EntityFramework.Plus.Internal.Core.SchemaObjectModel;

#elif EF7
#elif EFCORE
using System.Reflection;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Metadata;
Expand Down Expand Up @@ -155,7 +155,7 @@ public int Execute<T>(IQueryable<T> query) where T : class
innerObjectQuery.Context.Connection.Close();
}
}
#elif EF7
#elif EFCORE
var dbContext = query.GetDbContext();
var entity = dbContext.Model.FindEntityType(typeof (T));
var keys = entity.GetKeys().ToList()[0].Properties;
Expand Down Expand Up @@ -250,12 +250,16 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
var parameterCollection = query.Parameters;
foreach (var parameter in parameterCollection)
{
command.Parameters.Add(parameter);
var param = command.CreateParameter();
param.ParameterName = parameter.Name;
param.Value = parameter.Value;

command.Parameters.Add(param);
}

return command;
}
#elif EF7
#elif EFCORE
public DbCommand CreateCommand(IQueryable query, IEntityType entity)
{
var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.FullName == "EntityFramework.MicrosoftSqlServer, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60");
Expand Down Expand Up @@ -311,7 +315,11 @@ public DbCommand CreateCommand(IQueryable query, IEntityType entity)
var parameterCollection = relationalCommand.Parameters;
foreach (var parameter in parameterCollection)
{
command.Parameters.Add(parameter);
var param = command.CreateParameter();
param.ParameterName = parameter.Name;
param.Value = parameter.Value;

command.Parameters.Add(param);
}

return command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.

#if STANDALONE
#if EF7
#if EFCORE
using System.Data.Common;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.

#if STANDALONE
#if EF7
#if EFCORE
using System.Linq;
using System.Reflection;
using Microsoft.Data.Entity.Query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.

#if STANDALONE
#if EF7
#if EFCORE
using System.Linq;
using System.Reflection;
using Microsoft.Data.Entity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ internal static DbContext GetDbContext<T>(this IQueryable<T> query)
#if EF5
var provider = query.Provider;
var internalContextProperty = provider.GetType().GetProperty("InternalContext", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
var internalContext = internalContextProperty.GetValue(provider);
var internalContext = internalContextProperty.GetValue(provider, null);

var ownerProperty = internalContext.GetType().GetProperty("Owner", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
var owner = ownerProperty.GetValue(internalContext);
var owner = ownerProperty.GetValue(internalContext, null);
return (DbContext) owner;
#elif EF6
return query.GetObjectQuery().Context.GetDbContext();
Expand Down
26 changes: 17 additions & 9 deletions src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/BatchUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System.Data.Entity.Core.Objects;
using Z.EntityFramework.Plus.Internal.Core.SchemaObjectModel;

#elif EF7
#elif EFCORE
using System.Reflection;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Metadata;
Expand Down Expand Up @@ -163,7 +163,7 @@ public int Execute<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory)
innerObjectQuery.Context.Connection.Close();
}
}
#elif EF7
#elif EFCORE
var dbContext = query.GetDbContext();
var entity = dbContext.Model.FindEntityType(typeof (T));

Expand Down Expand Up @@ -272,7 +272,11 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
var parameterCollection = query.Parameters;
foreach (var parameter in parameterCollection)
{
command.Parameters.Add(parameter);
var param = command.CreateParameter();
param.ParameterName = parameter.Name;
param.Value = parameter.Value;

command.Parameters.Add(param);
}

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

return command;
}
#elif EF7
#elif EFCORE
public DbCommand CreateCommand(IQueryable query, IEntityType entity, List<Tuple<string, object>> values)
{
var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.FullName == "EntityFramework.MicrosoftSqlServer, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60");
Expand Down Expand Up @@ -355,7 +359,11 @@ public DbCommand CreateCommand(IQueryable query, IEntityType entity, List<Tuple<
var parameterCollection = relationalCommand.Parameters;
foreach (var parameter in parameterCollection)
{
command.Parameters.Add(parameter);
var param = command.CreateParameter();
param.ParameterName = parameter.Name;
param.Value = parameter.Value;

command.Parameters.Add(param);
}

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

#if EF5 || EF6
internal List<Tuple<string, object>> GetInnerValues<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory, SchemaEntityType<T> entity) where T : class
#elif EF7
#elif EFCORE
public List<Tuple<string, object>> GetInnerValues<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory, IEntityType entity) where T : class
#endif
{
#if EF5 || EF6
// GET mapping
var mapping = entity.Info.EntityTypeMapping.MappingFragment;
#elif EF7
#elif EFCORE
var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.FullName == "EntityFramework.MicrosoftSqlServer, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60");

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.

#if STANDALONE
#if EF7
#if EFCORE
using System.Data.Common;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.

#if STANDALONE
#if EF7
#if EFCORE
using System.Linq;
using System.Reflection;
using Microsoft.Data.Entity.Query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.

#if STANDALONE
#if EF7
#if EFCORE
using System.Linq;
using System.Reflection;
using Microsoft.Data.Entity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ internal static DbContext GetDbContext<T>(this IQueryable<T> query)
#if EF5
var provider = query.Provider;
var internalContextProperty = provider.GetType().GetProperty("InternalContext", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
var internalContext = internalContextProperty.GetValue(provider);
var internalContext = internalContextProperty.GetValue(provider, null);

var ownerProperty = internalContext.GetType().GetProperty("Owner", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
var owner = ownerProperty.GetValue(internalContext);
var owner = ownerProperty.GetValue(internalContext, null);
return (DbContext) owner;
#elif EF6
return query.GetObjectQuery().Context.GetDbContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("e4c2af73-caeb-4429-bcb6-0a359484e064")]
[assembly: AssemblyVersion("1.0.4")]
[assembly: AssemblyFileVersion("1.0.4")]
[assembly: AssemblyVersion("1.0.5")]
[assembly: AssemblyFileVersion("1.0.5")]
18 changes: 13 additions & 5 deletions src/Z.EntityFramework.Plus.EF5/BatchDelete/BatchDelete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using System.Data.Entity.Core.Objects;
using Z.EntityFramework.Plus.Internal.Core.SchemaObjectModel;

#elif EF7
#elif EFCORE
using System.Reflection;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Metadata;
Expand Down Expand Up @@ -155,7 +155,7 @@ public int Execute<T>(IQueryable<T> query) where T : class
innerObjectQuery.Context.Connection.Close();
}
}
#elif EF7
#elif EFCORE
var dbContext = query.GetDbContext();
var entity = dbContext.Model.FindEntityType(typeof (T));
var keys = entity.GetKeys().ToList()[0].Properties;
Expand Down Expand Up @@ -250,12 +250,16 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
var parameterCollection = query.Parameters;
foreach (var parameter in parameterCollection)
{
command.Parameters.Add(parameter);
var param = command.CreateParameter();
param.ParameterName = parameter.Name;
param.Value = parameter.Value;

command.Parameters.Add(param);
}

return command;
}
#elif EF7
#elif EFCORE
public DbCommand CreateCommand(IQueryable query, IEntityType entity)
{
var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.FullName == "EntityFramework.MicrosoftSqlServer, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60");
Expand Down Expand Up @@ -311,7 +315,11 @@ public DbCommand CreateCommand(IQueryable query, IEntityType entity)
var parameterCollection = relationalCommand.Parameters;
foreach (var parameter in parameterCollection)
{
command.Parameters.Add(parameter);
var param = command.CreateParameter();
param.ParameterName = parameter.Name;
param.Value = parameter.Value;

command.Parameters.Add(param);
}

return command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.

#if STANDALONE
#if EF7
#if EFCORE
using System.Data.Common;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.

#if STANDALONE
#if EF7
#if EFCORE
using System.Linq;
using System.Reflection;
using Microsoft.Data.Entity.Query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.

#if STANDALONE
#if EF7
#if EFCORE
using System.Linq;
using System.Reflection;
using Microsoft.Data.Entity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ internal static DbContext GetDbContext<T>(this IQueryable<T> query)
#if EF5
var provider = query.Provider;
var internalContextProperty = provider.GetType().GetProperty("InternalContext", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
var internalContext = internalContextProperty.GetValue(provider);
var internalContext = internalContextProperty.GetValue(provider, null);

var ownerProperty = internalContext.GetType().GetProperty("Owner", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
var owner = ownerProperty.GetValue(internalContext);
var owner = ownerProperty.GetValue(internalContext, null);
return (DbContext) owner;
#elif EF6
return query.GetObjectQuery().Context.GetDbContext();
Expand Down
Loading

0 comments on commit 81aad76

Please sign in to comment.