diff --git a/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/BatchDelete.cs b/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/BatchDelete.cs index 20e3d062..18be7535 100644 --- a/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/BatchDelete.cs +++ b/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/BatchDelete.cs @@ -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; @@ -155,7 +155,7 @@ public int Execute(IQueryable 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; @@ -250,12 +250,16 @@ internal DbCommand CreateCommand(ObjectQuery query, SchemaEntityType 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"); @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/DbContext.CreateStoreCommand.cs b/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/DbContext.CreateStoreCommand.cs index dea2d4e8..73006fb0 100644 --- a/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/DbContext.CreateStoreCommand.cs +++ b/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/DbContext.CreateStoreCommand.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.CreateCommand.cs b/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.CreateCommand.cs index 2908d758..a569a394 100644 --- a/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.CreateCommand.cs +++ b/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.CreateCommand.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs b/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs index 91ca7dbd..4c6482ff 100644 --- a/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs +++ b/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.GetDbContext.cs b/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.GetDbContext.cs index 1f250d38..0456a323 100644 --- a/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.GetDbContext.cs +++ b/src/Z.EntityFramework.Plus.EF5.NET40/BatchDelete/Standalone/Extensions/IQueryable`.GetDbContext.cs @@ -27,10 +27,10 @@ internal static DbContext GetDbContext(this IQueryable 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(); diff --git a/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/BatchUpdate.cs b/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/BatchUpdate.cs index e91b74d7..16ce7320 100644 --- a/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/BatchUpdate.cs +++ b/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/BatchUpdate.cs @@ -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; @@ -163,7 +163,7 @@ public int Execute(IQueryable query, Expression> updateFactory) innerObjectQuery.Context.Connection.Close(); } } -#elif EF7 +#elif EFCORE var dbContext = query.GetDbContext(); var entity = dbContext.Model.FindEntityType(typeof (T)); @@ -272,7 +272,11 @@ internal DbCommand CreateCommand(ObjectQuery query, SchemaEntityType 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++) @@ -292,7 +296,7 @@ internal DbCommand CreateCommand(ObjectQuery query, SchemaEntityType entit return command; } -#elif EF7 +#elif EFCORE public DbCommand CreateCommand(IQueryable query, IEntityType entity, List> values) { 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> GetInnerValues(IQueryable query, Expression> updateFactory, SchemaEntityType entity) where T : class -#elif EF7 +#elif EFCORE public List> GetInnerValues(IQueryable query, Expression> 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) @@ -415,7 +423,7 @@ public List> GetInnerValues(IQueryable 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}); @@ -458,7 +466,7 @@ public List> GetInnerValues(IQueryable 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; diff --git a/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/DbContext.CreateStoreCommand.cs b/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/DbContext.CreateStoreCommand.cs index dea2d4e8..73006fb0 100644 --- a/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/DbContext.CreateStoreCommand.cs +++ b/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/DbContext.CreateStoreCommand.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.CreateCommand.cs b/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.CreateCommand.cs index 2908d758..a569a394 100644 --- a/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.CreateCommand.cs +++ b/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.CreateCommand.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs b/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs index 91ca7dbd..4c6482ff 100644 --- a/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs +++ b/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.GetDbContext.cs b/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.GetDbContext.cs index 1f250d38..0456a323 100644 --- a/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.GetDbContext.cs +++ b/src/Z.EntityFramework.Plus.EF5.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.GetDbContext.cs @@ -27,10 +27,10 @@ internal static DbContext GetDbContext(this IQueryable 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(); diff --git a/src/Z.EntityFramework.Plus.EF5.NET40/Properties/AssemblyInfo.cs b/src/Z.EntityFramework.Plus.EF5.NET40/Properties/AssemblyInfo.cs index 4f2b14c2..5fd690fc 100644 --- a/src/Z.EntityFramework.Plus.EF5.NET40/Properties/AssemblyInfo.cs +++ b/src/Z.EntityFramework.Plus.EF5.NET40/Properties/AssemblyInfo.cs @@ -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")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.5")] +[assembly: AssemblyFileVersion("1.0.5")] \ No newline at end of file diff --git a/src/Z.EntityFramework.Plus.EF5/BatchDelete/BatchDelete.cs b/src/Z.EntityFramework.Plus.EF5/BatchDelete/BatchDelete.cs index 20e3d062..18be7535 100644 --- a/src/Z.EntityFramework.Plus.EF5/BatchDelete/BatchDelete.cs +++ b/src/Z.EntityFramework.Plus.EF5/BatchDelete/BatchDelete.cs @@ -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; @@ -155,7 +155,7 @@ public int Execute(IQueryable 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; @@ -250,12 +250,16 @@ internal DbCommand CreateCommand(ObjectQuery query, SchemaEntityType 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"); @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/DbContext.CreateStoreCommand.cs b/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/DbContext.CreateStoreCommand.cs index dea2d4e8..73006fb0 100644 --- a/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/DbContext.CreateStoreCommand.cs +++ b/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/DbContext.CreateStoreCommand.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/IQueryable`.CreateCommand.cs b/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/IQueryable`.CreateCommand.cs index 2908d758..a569a394 100644 --- a/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/IQueryable`.CreateCommand.cs +++ b/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/IQueryable`.CreateCommand.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs b/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs index 91ca7dbd..4c6482ff 100644 --- a/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs +++ b/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/IQueryable`.GetDbContext.cs b/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/IQueryable`.GetDbContext.cs index 1f250d38..0456a323 100644 --- a/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/IQueryable`.GetDbContext.cs +++ b/src/Z.EntityFramework.Plus.EF5/BatchDelete/Standalone/Extensions/IQueryable`.GetDbContext.cs @@ -27,10 +27,10 @@ internal static DbContext GetDbContext(this IQueryable 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(); diff --git a/src/Z.EntityFramework.Plus.EF5/BatchUpdate/BatchUpdate.cs b/src/Z.EntityFramework.Plus.EF5/BatchUpdate/BatchUpdate.cs index e91b74d7..16ce7320 100644 --- a/src/Z.EntityFramework.Plus.EF5/BatchUpdate/BatchUpdate.cs +++ b/src/Z.EntityFramework.Plus.EF5/BatchUpdate/BatchUpdate.cs @@ -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; @@ -163,7 +163,7 @@ public int Execute(IQueryable query, Expression> updateFactory) innerObjectQuery.Context.Connection.Close(); } } -#elif EF7 +#elif EFCORE var dbContext = query.GetDbContext(); var entity = dbContext.Model.FindEntityType(typeof (T)); @@ -272,7 +272,11 @@ internal DbCommand CreateCommand(ObjectQuery query, SchemaEntityType 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++) @@ -292,7 +296,7 @@ internal DbCommand CreateCommand(ObjectQuery query, SchemaEntityType entit return command; } -#elif EF7 +#elif EFCORE public DbCommand CreateCommand(IQueryable query, IEntityType entity, List> values) { 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> GetInnerValues(IQueryable query, Expression> updateFactory, SchemaEntityType entity) where T : class -#elif EF7 +#elif EFCORE public List> GetInnerValues(IQueryable query, Expression> 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) @@ -415,7 +423,7 @@ public List> GetInnerValues(IQueryable 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}); @@ -458,7 +466,7 @@ public List> GetInnerValues(IQueryable 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; diff --git a/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/DbContext.CreateStoreCommand.cs b/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/DbContext.CreateStoreCommand.cs index dea2d4e8..73006fb0 100644 --- a/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/DbContext.CreateStoreCommand.cs +++ b/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/DbContext.CreateStoreCommand.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/IQueryable`.CreateCommand.cs b/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/IQueryable`.CreateCommand.cs index 2908d758..a569a394 100644 --- a/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/IQueryable`.CreateCommand.cs +++ b/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/IQueryable`.CreateCommand.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs b/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs index 91ca7dbd..4c6482ff 100644 --- a/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs +++ b/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/IQueryable`.GetDbContext.cs b/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/IQueryable`.GetDbContext.cs index 1f250d38..0456a323 100644 --- a/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/IQueryable`.GetDbContext.cs +++ b/src/Z.EntityFramework.Plus.EF5/BatchUpdate/Standalone/Extensions/IQueryable`.GetDbContext.cs @@ -27,10 +27,10 @@ internal static DbContext GetDbContext(this IQueryable 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(); diff --git a/src/Z.EntityFramework.Plus.EF5/Properties/AssemblyInfo.cs b/src/Z.EntityFramework.Plus.EF5/Properties/AssemblyInfo.cs index 2e2c050b..13479199 100644 --- a/src/Z.EntityFramework.Plus.EF5/Properties/AssemblyInfo.cs +++ b/src/Z.EntityFramework.Plus.EF5/Properties/AssemblyInfo.cs @@ -18,5 +18,5 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("abcbb878-043c-4957-a334-90e9872e684e")] -[assembly: AssemblyVersion("1.0.4")] -[assembly: AssemblyFileVersion("1.0.4")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.5")] +[assembly: AssemblyFileVersion("1.0.5")] \ No newline at end of file diff --git a/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/BatchDelete.cs b/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/BatchDelete.cs index 20e3d062..18be7535 100644 --- a/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/BatchDelete.cs +++ b/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/BatchDelete.cs @@ -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; @@ -155,7 +155,7 @@ public int Execute(IQueryable 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; @@ -250,12 +250,16 @@ internal DbCommand CreateCommand(ObjectQuery query, SchemaEntityType 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"); @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/DbContext.CreateStoreCommand.cs b/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/DbContext.CreateStoreCommand.cs index dea2d4e8..73006fb0 100644 --- a/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/DbContext.CreateStoreCommand.cs +++ b/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/DbContext.CreateStoreCommand.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/IQueryable`.CreateCommand.cs b/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/IQueryable`.CreateCommand.cs index 2908d758..a569a394 100644 --- a/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/IQueryable`.CreateCommand.cs +++ b/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/IQueryable`.CreateCommand.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs b/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs index 91ca7dbd..4c6482ff 100644 --- a/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs +++ b/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/IQueryable`.GetDbContext.cs b/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/IQueryable`.GetDbContext.cs index 1f250d38..0456a323 100644 --- a/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/IQueryable`.GetDbContext.cs +++ b/src/Z.EntityFramework.Plus.EF6.NET40/BatchDelete/Standalone/Extensions/IQueryable`.GetDbContext.cs @@ -27,10 +27,10 @@ internal static DbContext GetDbContext(this IQueryable 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(); diff --git a/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/BatchUpdate.cs b/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/BatchUpdate.cs index e91b74d7..16ce7320 100644 --- a/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/BatchUpdate.cs +++ b/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/BatchUpdate.cs @@ -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; @@ -163,7 +163,7 @@ public int Execute(IQueryable query, Expression> updateFactory) innerObjectQuery.Context.Connection.Close(); } } -#elif EF7 +#elif EFCORE var dbContext = query.GetDbContext(); var entity = dbContext.Model.FindEntityType(typeof (T)); @@ -272,7 +272,11 @@ internal DbCommand CreateCommand(ObjectQuery query, SchemaEntityType 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++) @@ -292,7 +296,7 @@ internal DbCommand CreateCommand(ObjectQuery query, SchemaEntityType entit return command; } -#elif EF7 +#elif EFCORE public DbCommand CreateCommand(IQueryable query, IEntityType entity, List> values) { 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> GetInnerValues(IQueryable query, Expression> updateFactory, SchemaEntityType entity) where T : class -#elif EF7 +#elif EFCORE public List> GetInnerValues(IQueryable query, Expression> 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) @@ -415,7 +423,7 @@ public List> GetInnerValues(IQueryable 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}); @@ -458,7 +466,7 @@ public List> GetInnerValues(IQueryable 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; diff --git a/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/DbContext.CreateStoreCommand.cs b/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/DbContext.CreateStoreCommand.cs index dea2d4e8..73006fb0 100644 --- a/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/DbContext.CreateStoreCommand.cs +++ b/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/DbContext.CreateStoreCommand.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.CreateCommand.cs b/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.CreateCommand.cs index 2908d758..a569a394 100644 --- a/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.CreateCommand.cs +++ b/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.CreateCommand.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs b/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs index 91ca7dbd..4c6482ff 100644 --- a/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs +++ b/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.EF7.GetDbContext.cs @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.GetDbContext.cs b/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.GetDbContext.cs index 1f250d38..0456a323 100644 --- a/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.GetDbContext.cs +++ b/src/Z.EntityFramework.Plus.EF6.NET40/BatchUpdate/Standalone/Extensions/IQueryable`.GetDbContext.cs @@ -27,10 +27,10 @@ internal static DbContext GetDbContext(this IQueryable 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(); diff --git a/src/Z.EntityFramework.Plus.EF6.NET40/Properties/AssemblyInfo.cs b/src/Z.EntityFramework.Plus.EF6.NET40/Properties/AssemblyInfo.cs index 6e8850a9..dfc98250 100644 --- a/src/Z.EntityFramework.Plus.EF6.NET40/Properties/AssemblyInfo.cs +++ b/src/Z.EntityFramework.Plus.EF6.NET40/Properties/AssemblyInfo.cs @@ -18,5 +18,5 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("ac398eb8-0a31-4d06-a804-84d10b6da96d")] -[assembly: AssemblyVersion("1.0.4")] -[assembly: AssemblyFileVersion("1.0.4")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.5")] +[assembly: AssemblyFileVersion("1.0.5")] \ No newline at end of file diff --git a/src/Z.EntityFramework.Plus.EF6/Audit/Extensions/DbContext/SaveChanges.cs b/src/Z.EntityFramework.Plus.EF6/Audit/Extensions/DbContext/SaveChanges.cs index 5b4dee8a..30f09179 100644 --- a/src/Z.EntityFramework.Plus.EF6/Audit/Extensions/DbContext/SaveChanges.cs +++ b/src/Z.EntityFramework.Plus.EF6/Audit/Extensions/DbContext/SaveChanges.cs @@ -20,7 +20,7 @@ public static partial class AuditExtensions /// Audits and saves all changes made in this context to the underlying database. /// The context used to audits and saves all changes made. /// The audit to use to add changes made to the context. - /// The number of objects written to the underlying database. + /// The number of objects written to the underlying database.- public static int SaveChanges(this DbContext context, Audit audit) { audit.PreSaveChanges(context); diff --git a/src/Z.EntityFramework.Plus.EF6/BatchDelete/BatchDelete.cs b/src/Z.EntityFramework.Plus.EF6/BatchDelete/BatchDelete.cs index c952eb0e..18be7535 100644 --- a/src/Z.EntityFramework.Plus.EF6/BatchDelete/BatchDelete.cs +++ b/src/Z.EntityFramework.Plus.EF6/BatchDelete/BatchDelete.cs @@ -250,7 +250,11 @@ internal DbCommand CreateCommand(ObjectQuery query, SchemaEntityType 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; @@ -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; diff --git a/src/Z.EntityFramework.Plus.EF6/BatchUpdate/BatchUpdate.cs b/src/Z.EntityFramework.Plus.EF6/BatchUpdate/BatchUpdate.cs index 3875e502..16ce7320 100644 --- a/src/Z.EntityFramework.Plus.EF6/BatchUpdate/BatchUpdate.cs +++ b/src/Z.EntityFramework.Plus.EF6/BatchUpdate/BatchUpdate.cs @@ -272,7 +272,11 @@ internal DbCommand CreateCommand(ObjectQuery query, SchemaEntityType 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++) @@ -355,7 +359,11 @@ public DbCommand CreateCommand(IQueryable query, IEntityType entity, List(ObjectQuery query, SchemaEntityType 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; @@ -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; diff --git a/src/Z.EntityFramework.Plus.EFCore/BatchUpdate/BatchUpdate.cs b/src/Z.EntityFramework.Plus.EFCore/BatchUpdate/BatchUpdate.cs index 3875e502..16ce7320 100644 --- a/src/Z.EntityFramework.Plus.EFCore/BatchUpdate/BatchUpdate.cs +++ b/src/Z.EntityFramework.Plus.EFCore/BatchUpdate/BatchUpdate.cs @@ -272,7 +272,11 @@ internal DbCommand CreateCommand(ObjectQuery query, SchemaEntityType 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++) @@ -355,7 +359,11 @@ public DbCommand CreateCommand(IQueryable query, IEntityType entity, List Debug AnyCPU - {01BCB005-E336-4D9D-897D-3B7CD887AE55} + {C41195F5-937E-4F2B-9F36-20650A804CAA} Library Properties Z.EntityFramework.Plus.EFCore @@ -204,10 +204,12 @@ - Component + + - Component + + diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/BatchDelete_WhereValue.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/BatchDelete_WhereValue.cs new file mode 100644 index 00000000..3ed03c7c --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/BatchDelete_WhereValue.cs @@ -0,0 +1,16 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Test.EntityFramework.Plus +{ + [TestClass] + public partial class BatchDelete_WhereValue + { + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Executing/Template.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Executing/Template.cs index b122c2cb..4412c07a 100644 --- a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Executing/Template.cs +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Executing/Template.cs @@ -63,7 +63,7 @@ FROM [dbo].[Entity_Basic] AS [Extent1] SELECT @@ROWCOUNT ", sql); -#elif EF7 +#elif EFCORE Assert.AreEqual(@" DELETE FROM A diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Executing/WhileDelayTemplate.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Executing/WhileDelayTemplate.cs index d2062621..d7adef26 100644 --- a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Executing/WhileDelayTemplate.cs +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Executing/WhileDelayTemplate.cs @@ -97,7 +97,7 @@ FROM [dbo].[Entity_Basic] AS [Extent1] SELECT @totalRowAffected ", sql); -#elif EF7 +#elif EFCORE Assert.AreEqual(@" DECLARE @rowAffected INT DECLARE @totalRowAffected INT diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Executing/WhileTemplate.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Executing/WhileTemplate.cs index 384b29e1..4b643a72 100644 --- a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Executing/WhileTemplate.cs +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Executing/WhileTemplate.cs @@ -83,7 +83,7 @@ FROM [dbo].[Entity_Basic] AS [Extent1] SELECT @totalRowAffected ", sql); -#elif EF7 +#elif EFCORE Assert.AreEqual(@" DECLARE @rowAffected INT DECLARE @totalRowAffected INT diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Transaction/Commit.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Transaction/Commit.cs index ad98a28b..00b484bc 100644 --- a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Transaction/Commit.cs +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Transaction/Commit.cs @@ -5,11 +5,11 @@ // More projects: http://www.zzzprojects.com/ // Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. -#if EF6 || EF7 +#if EF6 || EFCORE using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using Z.EntityFramework.Plus; -#if EF7 +#if EFCORE using Microsoft.Data.Entity; #endif diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Transaction/Rollback.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Transaction/Rollback.cs index e47c5707..e232dd58 100644 --- a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Transaction/Rollback.cs +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/Transaction/Rollback.cs @@ -5,11 +5,11 @@ // More projects: http://www.zzzprojects.com/ // Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. -#if EF6 || EF7 +#if EF6 || EFCORE using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using Z.EntityFramework.Plus; -#if EF7 +#if EFCORE using Microsoft.Data.Entity; #endif diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/WhereValue/Many_Constant.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/WhereValue/Many_Constant.cs new file mode 100644 index 00000000..89acc67d --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/WhereValue/Many_Constant.cs @@ -0,0 +1,36 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchDelete_WhereValue + { + [TestMethod] + public void Many_Constant() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > 10 && x.ColumnInt <= 40).Delete(); + + // AFTER + Assert.AreEqual(460, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(30, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/WhereValue/Many_Variable.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/WhereValue/Many_Variable.cs new file mode 100644 index 00000000..76cb63e2 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/WhereValue/Many_Variable.cs @@ -0,0 +1,38 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchDelete_WhereValue + { + [TestMethod] + public void Many_Variable() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + int minValue = 10; + int maxValue = 40; + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > minValue && x.ColumnInt <= maxValue).Delete(); + + // AFTER + Assert.AreEqual(460, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(30, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/WhereValue/Single_Constant.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/WhereValue/Single_Constant.cs new file mode 100644 index 00000000..a198a2f2 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/WhereValue/Single_Constant.cs @@ -0,0 +1,36 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchDelete_WhereValue + { + [TestMethod] + public void Single_Constant() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > 10).Delete(); + + // AFTER + Assert.AreEqual(55, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(39, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/WhereValue/Single_Variable.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/WhereValue/Single_Variable.cs new file mode 100644 index 00000000..96bcba6f --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchDelete/WhereValue/Single_Variable.cs @@ -0,0 +1,37 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchDelete_WhereValue + { + [TestMethod] + public void Single_Variable() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + int minValue = 10; + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > minValue).Delete(); + + // AFTER + Assert.AreEqual(55, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(39, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/BatchUpdate_WhereValue.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/BatchUpdate_WhereValue.cs new file mode 100644 index 00000000..9cba9d57 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/BatchUpdate_WhereValue.cs @@ -0,0 +1,16 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Test.EntityFramework.Plus +{ + [TestClass] + public partial class BatchUpdate_WhereValue + { + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/Executing/WhileTemplate.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/Executing/WhileTemplate.cs index f4a742c6..a17f1e23 100644 --- a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/Executing/WhileTemplate.cs +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/Executing/WhileTemplate.cs @@ -57,7 +57,7 @@ FROM [dbo].[Entity_Basic] AS [Extent1] WHERE ([Extent1].[ColumnInt] > 10) AND ([Extent1].[ColumnInt] <= 40) ) AS B ON A.[ID] = B.[ID] ", sql); -#elif EF7 +#elif EFCORE Assert.AreEqual(@" UPDATE A SET A.[ColumnInt] = @zzz_BatchUpdate_0 diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/Transaction/Commit.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/Transaction/Commit.cs index 6ed564dd..c1301222 100644 --- a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/Transaction/Commit.cs +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/Transaction/Commit.cs @@ -5,11 +5,11 @@ // More projects: http://www.zzzprojects.com/ // Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. -#if EF6 || EF7 +#if EF6 || EFCORE using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using Z.EntityFramework.Plus; -#if EF7 +#if EFCORE using Microsoft.Data.Entity; #endif diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/Transaction/Rollback.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/Transaction/Rollback.cs index ff7aca3b..35ced9e8 100644 --- a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/Transaction/Rollback.cs +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/Transaction/Rollback.cs @@ -5,11 +5,11 @@ // More projects: http://www.zzzprojects.com/ // Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. -#if EF6 || EF7 +#if EF6 || EFCORE using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using Z.EntityFramework.Plus; -#if EF7 +#if EFCORE using Microsoft.Data.Entity; #endif diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/WhereValue/Many_Constant.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/WhereValue/Many_Constant.cs new file mode 100644 index 00000000..7f39d2eb --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/WhereValue/Many_Constant.cs @@ -0,0 +1,36 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchUpdate_WhereValue + { + [TestMethod] + public void Many_Constant() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > 10 && x.ColumnInt <= 40).Update(x => new Entity_Basic { ColumnInt = 99 }); + + // AFTER + Assert.AreEqual(3430, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(30, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/WhereValue/Many_Variable.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/WhereValue/Many_Variable.cs new file mode 100644 index 00000000..a05db1d4 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/WhereValue/Many_Variable.cs @@ -0,0 +1,38 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchUpdate_WhereValue + { + [TestMethod] + public void Many_Variable() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var minValue = 10; + var maxValue = 40; + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > minValue && x.ColumnInt <= maxValue).Update(x => new Entity_Basic { ColumnInt = 99 }); + + // AFTER + Assert.AreEqual(3430, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(30, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/WhereValue/Single_Constant.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/WhereValue/Single_Constant.cs new file mode 100644 index 00000000..1a6c3244 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/WhereValue/Single_Constant.cs @@ -0,0 +1,36 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchUpdate_WhereValue + { + [TestMethod] + public void Single_Constant() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > 10).Update(x => new Entity_Basic {ColumnInt = 99}); + + // AFTER + Assert.AreEqual(3916, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(39, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/WhereValue/Single_Variable.cs b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/WhereValue/Single_Variable.cs new file mode 100644 index 00000000..de87840b --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/BatchUpdate/WhereValue/Single_Variable.cs @@ -0,0 +1,37 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchUpdate_WhereValue + { + [TestMethod] + public void Single_Variable() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var minValue = 10; + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > minValue).Update(x => new Entity_Basic {ColumnInt = 99}); + + // AFTER + Assert.AreEqual(3916, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(39, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF5/Z.Test.EntityFramework.Plus.EF5.csproj b/src/test/Z.Test.EntityFramework.Plus.EF5/Z.Test.EntityFramework.Plus.EF5.csproj index e8301ef7..79109d01 100644 --- a/src/test/Z.Test.EntityFramework.Plus.EF5/Z.Test.EntityFramework.Plus.EF5.csproj +++ b/src/test/Z.Test.EntityFramework.Plus.EF5/Z.Test.EntityFramework.Plus.EF5.csproj @@ -162,6 +162,7 @@ + @@ -175,6 +176,10 @@ + + + + @@ -196,6 +201,7 @@ + @@ -221,6 +227,10 @@ + + + + diff --git a/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/BatchDelete_WhereValue.cs b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/BatchDelete_WhereValue.cs new file mode 100644 index 00000000..3ed03c7c --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/BatchDelete_WhereValue.cs @@ -0,0 +1,16 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Test.EntityFramework.Plus +{ + [TestClass] + public partial class BatchDelete_WhereValue + { + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/WhereValue/Many_Constant.cs b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/WhereValue/Many_Constant.cs new file mode 100644 index 00000000..89acc67d --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/WhereValue/Many_Constant.cs @@ -0,0 +1,36 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchDelete_WhereValue + { + [TestMethod] + public void Many_Constant() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > 10 && x.ColumnInt <= 40).Delete(); + + // AFTER + Assert.AreEqual(460, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(30, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/WhereValue/Many_Variable.cs b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/WhereValue/Many_Variable.cs new file mode 100644 index 00000000..76cb63e2 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/WhereValue/Many_Variable.cs @@ -0,0 +1,38 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchDelete_WhereValue + { + [TestMethod] + public void Many_Variable() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + int minValue = 10; + int maxValue = 40; + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > minValue && x.ColumnInt <= maxValue).Delete(); + + // AFTER + Assert.AreEqual(460, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(30, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/WhereValue/Single_Constant.cs b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/WhereValue/Single_Constant.cs new file mode 100644 index 00000000..a198a2f2 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/WhereValue/Single_Constant.cs @@ -0,0 +1,36 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchDelete_WhereValue + { + [TestMethod] + public void Single_Constant() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > 10).Delete(); + + // AFTER + Assert.AreEqual(55, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(39, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/WhereValue/Single_Variable.cs b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/WhereValue/Single_Variable.cs new file mode 100644 index 00000000..96bcba6f --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchDelete/WhereValue/Single_Variable.cs @@ -0,0 +1,37 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchDelete_WhereValue + { + [TestMethod] + public void Single_Variable() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + int minValue = 10; + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > minValue).Delete(); + + // AFTER + Assert.AreEqual(55, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(39, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/BatchUpdate_WhereValue.cs b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/BatchUpdate_WhereValue.cs new file mode 100644 index 00000000..9cba9d57 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/BatchUpdate_WhereValue.cs @@ -0,0 +1,16 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Test.EntityFramework.Plus +{ + [TestClass] + public partial class BatchUpdate_WhereValue + { + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/WhereValue/Many_Constant.cs b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/WhereValue/Many_Constant.cs new file mode 100644 index 00000000..7f39d2eb --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/WhereValue/Many_Constant.cs @@ -0,0 +1,36 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchUpdate_WhereValue + { + [TestMethod] + public void Many_Constant() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > 10 && x.ColumnInt <= 40).Update(x => new Entity_Basic { ColumnInt = 99 }); + + // AFTER + Assert.AreEqual(3430, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(30, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/WhereValue/Many_Variable.cs b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/WhereValue/Many_Variable.cs new file mode 100644 index 00000000..a05db1d4 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/WhereValue/Many_Variable.cs @@ -0,0 +1,38 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchUpdate_WhereValue + { + [TestMethod] + public void Many_Variable() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var minValue = 10; + var maxValue = 40; + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > minValue && x.ColumnInt <= maxValue).Update(x => new Entity_Basic { ColumnInt = 99 }); + + // AFTER + Assert.AreEqual(3430, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(30, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/WhereValue/Single_Constant.cs b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/WhereValue/Single_Constant.cs new file mode 100644 index 00000000..1a6c3244 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/WhereValue/Single_Constant.cs @@ -0,0 +1,36 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchUpdate_WhereValue + { + [TestMethod] + public void Single_Constant() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > 10).Update(x => new Entity_Basic {ColumnInt = 99}); + + // AFTER + Assert.AreEqual(3916, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(39, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/WhereValue/Single_Variable.cs b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/WhereValue/Single_Variable.cs new file mode 100644 index 00000000..de87840b --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF6/BatchUpdate/WhereValue/Single_Variable.cs @@ -0,0 +1,37 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchUpdate_WhereValue + { + [TestMethod] + public void Single_Variable() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var minValue = 10; + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > minValue).Update(x => new Entity_Basic {ColumnInt = 99}); + + // AFTER + Assert.AreEqual(3916, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(39, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF6/Z.Test.EntityFramework.Plus.EF6.csproj b/src/test/Z.Test.EntityFramework.Plus.EF6/Z.Test.EntityFramework.Plus.EF6.csproj index 5c07d765..aaf3096c 100644 --- a/src/test/Z.Test.EntityFramework.Plus.EF6/Z.Test.EntityFramework.Plus.EF6.csproj +++ b/src/test/Z.Test.EntityFramework.Plus.EF6/Z.Test.EntityFramework.Plus.EF6.csproj @@ -150,8 +150,13 @@ + + + + + @@ -167,6 +172,7 @@ + @@ -224,6 +230,10 @@ + + + + @@ -389,6 +399,7 @@ + diff --git a/src/test/Z.Test.EntityFramework.Plus.EF6/_Model/Entity_Enum.cs b/src/test/Z.Test.EntityFramework.Plus.EF6/_Model/Entity_Enum.cs new file mode 100644 index 00000000..13c67c45 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EF6/_Model/Entity_Enum.cs @@ -0,0 +1,20 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System; + +namespace Z.Test.EntityFramework.Plus +{ + public class Entity_Enum + { + public int ID { get; set; } + + public int ColumnInt { get; set; } + + public DayOfWeek Day { get; set; } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EF6/_Model/_TestContext.cs b/src/test/Z.Test.EntityFramework.Plus.EF6/_Model/_TestContext.cs index 93555aea..15074b10 100644 --- a/src/test/Z.Test.EntityFramework.Plus.EF6/_Model/_TestContext.cs +++ b/src/test/Z.Test.EntityFramework.Plus.EF6/_Model/_TestContext.cs @@ -5,6 +5,8 @@ // More projects: http://www.zzzprojects.com/ // Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. +using System.Data.Common; +using System.Data.Entity.Infrastructure.Interception; using System.Data.SqlClient; using System.Linq; using Z.EntityFramework.Plus; @@ -20,6 +22,8 @@ namespace Z.Test.EntityFramework.Plus { + + #if EF5 || EF6 public class TestContextInitializer : CreateDatabaseIfNotExists { @@ -56,6 +60,8 @@ public TestContext() #elif EFCORE Database.EnsureCreated(); #endif + + } @@ -334,11 +340,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) #if EF5 || EF6 public DbSet Entity_Complexes { get; set; } + + public DbSet Entity_Enums { get; set; } #endif -#endregion + #endregion -#region Inheritance + #region Inheritance public DbSet Inheritance_Interface_Entities { get; set; } diff --git a/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/BatchDelete_WhereValue.cs b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/BatchDelete_WhereValue.cs new file mode 100644 index 00000000..3ed03c7c --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/BatchDelete_WhereValue.cs @@ -0,0 +1,16 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Test.EntityFramework.Plus +{ + [TestClass] + public partial class BatchDelete_WhereValue + { + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/WhereValue/Many_Constant.cs b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/WhereValue/Many_Constant.cs new file mode 100644 index 00000000..89acc67d --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/WhereValue/Many_Constant.cs @@ -0,0 +1,36 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchDelete_WhereValue + { + [TestMethod] + public void Many_Constant() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > 10 && x.ColumnInt <= 40).Delete(); + + // AFTER + Assert.AreEqual(460, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(30, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/WhereValue/Many_Variable.cs b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/WhereValue/Many_Variable.cs new file mode 100644 index 00000000..76cb63e2 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/WhereValue/Many_Variable.cs @@ -0,0 +1,38 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchDelete_WhereValue + { + [TestMethod] + public void Many_Variable() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + int minValue = 10; + int maxValue = 40; + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > minValue && x.ColumnInt <= maxValue).Delete(); + + // AFTER + Assert.AreEqual(460, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(30, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/WhereValue/Single_Constant.cs b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/WhereValue/Single_Constant.cs new file mode 100644 index 00000000..a198a2f2 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/WhereValue/Single_Constant.cs @@ -0,0 +1,36 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchDelete_WhereValue + { + [TestMethod] + public void Single_Constant() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > 10).Delete(); + + // AFTER + Assert.AreEqual(55, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(39, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/WhereValue/Single_Variable.cs b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/WhereValue/Single_Variable.cs new file mode 100644 index 00000000..96bcba6f --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchDelete/WhereValue/Single_Variable.cs @@ -0,0 +1,37 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchDelete_WhereValue + { + [TestMethod] + public void Single_Variable() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + int minValue = 10; + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > minValue).Delete(); + + // AFTER + Assert.AreEqual(55, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(39, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/BatchUpdate_WhereValue.cs b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/BatchUpdate_WhereValue.cs new file mode 100644 index 00000000..9cba9d57 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/BatchUpdate_WhereValue.cs @@ -0,0 +1,16 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Test.EntityFramework.Plus +{ + [TestClass] + public partial class BatchUpdate_WhereValue + { + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/WhereValue/Many_Constant.cs b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/WhereValue/Many_Constant.cs new file mode 100644 index 00000000..7f39d2eb --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/WhereValue/Many_Constant.cs @@ -0,0 +1,36 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchUpdate_WhereValue + { + [TestMethod] + public void Many_Constant() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > 10 && x.ColumnInt <= 40).Update(x => new Entity_Basic { ColumnInt = 99 }); + + // AFTER + Assert.AreEqual(3430, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(30, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/WhereValue/Many_Variable.cs b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/WhereValue/Many_Variable.cs new file mode 100644 index 00000000..a05db1d4 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/WhereValue/Many_Variable.cs @@ -0,0 +1,38 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchUpdate_WhereValue + { + [TestMethod] + public void Many_Variable() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var minValue = 10; + var maxValue = 40; + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > minValue && x.ColumnInt <= maxValue).Update(x => new Entity_Basic { ColumnInt = 99 }); + + // AFTER + Assert.AreEqual(3430, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(30, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/WhereValue/Single_Constant.cs b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/WhereValue/Single_Constant.cs new file mode 100644 index 00000000..1a6c3244 --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/WhereValue/Single_Constant.cs @@ -0,0 +1,36 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchUpdate_WhereValue + { + [TestMethod] + public void Single_Constant() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > 10).Update(x => new Entity_Basic {ColumnInt = 99}); + + // AFTER + Assert.AreEqual(3916, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(39, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/WhereValue/Single_Variable.cs b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/WhereValue/Single_Variable.cs new file mode 100644 index 00000000..de87840b --- /dev/null +++ b/src/test/Z.Test.EntityFramework.Plus.EFCore/BatchUpdate/WhereValue/Single_Variable.cs @@ -0,0 +1,37 @@ +// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit) +// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus +// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues +// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE +// More projects: http://www.zzzprojects.com/ +// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. + +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Z.EntityFramework.Plus; + +namespace Z.Test.EntityFramework.Plus +{ + public partial class BatchUpdate_WhereValue + { + [TestMethod] + public void Single_Variable() + { + TestContext.DeleteAll(x => x.Entity_Basics); + TestContext.Insert(x => x.Entity_Basics, 50); + + using (var ctx = new TestContext()) + { + // BEFORE + Assert.AreEqual(1225, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + + // ACTION + var minValue = 10; + var rowsAffected = ctx.Entity_Basics.Where(x => x.ColumnInt > minValue).Update(x => new Entity_Basic {ColumnInt = 99}); + + // AFTER + Assert.AreEqual(3916, ctx.Entity_Basics.Sum(x => x.ColumnInt)); + Assert.AreEqual(39, rowsAffected); + } + } + } +} \ No newline at end of file diff --git a/src/test/Z.Test.EntityFramework.Plus.EFCore/Z.Test.EntityFramework.Plus.EFCore.csproj b/src/test/Z.Test.EntityFramework.Plus.EFCore/Z.Test.EntityFramework.Plus.EFCore.csproj index 522e76ef..c231a1eb 100644 --- a/src/test/Z.Test.EntityFramework.Plus.EFCore/Z.Test.EntityFramework.Plus.EFCore.csproj +++ b/src/test/Z.Test.EntityFramework.Plus.EFCore/Z.Test.EntityFramework.Plus.EFCore.csproj @@ -3,7 +3,7 @@ Debug AnyCPU - {29838946-1188-4919-9FF2-BF9FEC9E2D9B} + {C47F920B-8064-44B0-BF3F-CD29298597A0} Library Properties Z.Test.EntityFramework.Plus.EFCore @@ -225,6 +225,7 @@ + @@ -238,6 +239,10 @@ + + + + @@ -259,6 +264,7 @@ + @@ -284,6 +290,10 @@ + + + +