Skip to content

Commit

Permalink
Merge pull request #462 from paillave/Scheduler
Browse files Browse the repository at this point in the history
dotnet version for delete
  • Loading branch information
paillave committed Jul 2, 2023
2 parents a34dac6 + 2d456a6 commit 7dd942f
Show file tree
Hide file tree
Showing 27 changed files with 65 additions and 62 deletions.
38 changes: 31 additions & 7 deletions src/Paillave.EntityFrameworkCoreExtension/Core/EfExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,37 @@ public static EntityEntry<TEntity> EntryWithoutDetectChanges<TEntity>(this DbCon
return (EntityEntry<TEntity>)entryWithoutDetectChangesMethodInfo.Invoke(context, new object[] { entity });
}
private static Regex regex = new Regex(@"SELECT\s+(?<ref>[[]?.+?[]]?)[.].+?\sFROM", RegexOptions.Singleline & RegexOptions.IgnoreCase);
public static Task DeleteWhereAsync<T>(this DbSet<T> dbSet, Expression<Func<T, bool>> filter) where T : class
=> DeleteWhereAsync(dbSet, filter, CancellationToken.None);
[System.Diagnostics.CodeAnalysis.SuppressMessage("Security", "CA2100:Review SQL queries for security vulnerabilities", Justification = "Reviewed")]
public static async Task DeleteWhereAsync<T>(this DbSet<T> dbSet, Expression<Func<T, bool>> filter, CancellationToken cancellationToken) where T : class
{
await dbSet.Where(filter).ExecuteDeleteAsync();
}
// public static Task DeleteWhereAsync<T>(this DbSet<T> dbSet, Expression<Func<T, bool>> filter) where T : class
// => DeleteWhereAsync(dbSet, filter, CancellationToken.None);
// [System.Diagnostics.CodeAnalysis.SuppressMessage("Security", "CA2100:Review SQL queries for security vulnerabilities", Justification = "Reviewed")]
// public static async Task DeleteWhereAsync<T>(this DbSet<T> dbSet, Expression<Func<T, bool>> filter, CancellationToken cancellationToken) where T : class
// {
// await dbSet.Where(filter).ExecuteDeleteAsync(); //return type exception because of unexpected joins EF core makes for some reason I don't get
// // var query = dbSet.Where(filter);
// // var enumerator = query.Provider.Execute<IEnumerable<T>>(query.Expression).GetEnumerator();
// // var relationalCommandCache = enumerator.Private("_relationalCommandCache");
// // var relationQueryContext = enumerator.Private<RelationalQueryContext>("_relationalQueryContext");
// // var selectExpression = relationalCommandCache.Private<SelectExpression>("_selectExpression");
// // var factory = relationalCommandCache.Private<IQuerySqlGeneratorFactory>("_querySqlGeneratorFactory");

// // var sqlGenerator = factory.Create();
// // var command = sqlGenerator.GetCommand(selectExpression);
// // var parameterValues = relationQueryContext.ParameterValues;
// // var dbCtx = relationQueryContext.Context.Database.GetDbConnection();
// // var dbCommand = dbCtx.CreateCommand();
// // if (dbCtx.State == ConnectionState.Closed)
// // {
// // dbCtx.Open();
// // }
// // string deleteSql = regex.Replace(command.CommandText, "DELETE $1 FROM", 1);
// // // dbCommand.Transaction = relationQueryContext.Context.Database.CurrentTransaction as System.Data.Common.DbTransaction;
// // dbCommand.CommandText = deleteSql;
// // dbCommand.CommandType = CommandType.Text;
// // dbCommand.CommandTimeout = 3000;
// // foreach (var parameter in command.Parameters)
// // parameter.AddDbParameter(dbCommand, parameterValues[parameter.InvariantName]);
// // await dbCommand.ExecuteNonQueryAsync(cancellationToken);
// }

public static Expression<Func<T1, TResult>> ApplyPartialRight<T1, T2, TResult>(this Expression<Func<T1, T2, TResult>> expression, Expression expressionValue)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EntityFrameworkCoreExtension</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand All @@ -24,9 +24,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FastMember" Version="1.5.0" allowedVersions="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" allowedVersions="6.0.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" allowedVersions="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="7.0.5" allowedVersions="6.0.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.8" allowedVersions="6.0.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.8" allowedVersions="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="7.0.8" allowedVersions="6.0.0"/>
<PackageReference Include="system.data.sqlclient" Version="4.8.5" allowedVersions="4.8.0"/>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Paillave.Etl.Autofac/Paillave.Etl.Autofac.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.Autofac</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.Bloomberg/Paillave.Etl.Bloomberg.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.Bloomberg</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.Dropbox/Paillave.Etl.Dropbox.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.Dropbox</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Paillave.Etl.Reactive.Operators;
using Microsoft.EntityFrameworkCore;
using Paillave.EntityFrameworkCoreExtension.Core;
using System.Linq;

namespace Paillave.Etl.EntityFrameworkCore
{
Expand Down Expand Up @@ -109,7 +110,7 @@ protected override IStream<TIn> CreateOutputStream(DeleteEntityFrameworkCoreArgs
TValue val = args.GetValue(i);
this.ExecutionContext.InvokeInDedicatedThreadAsync(ctx, async () =>
{
await ctx.Set<TEntity>().DeleteWhereAsync(args.Match.ApplyPartialLeft<TValue, TEntity, bool>(val), args.InputStream.Observable.CancellationToken);
await ctx.Set<TEntity>().Where(args.Match.ApplyPartialLeft<TValue, TEntity, bool>(val)).ExecuteDeleteAsync(args.InputStream.Observable.CancellationToken);
}).Wait();
return i;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,6 @@ namespace Paillave.Etl.EntityFrameworkCore
{
public static class EntityFrameworkCoreDeleteEx
{
// [Obsolete]
// public static IStream<TIn> EfCoreDelete<TIn, TEntity>(this IStream<TIn> inputStream, string name, Expression<Func<TIn, TEntity, bool>> match)
// where TEntity : class
// {
// return new DeleteEntityFrameworkCoreStreamNode<TIn, TIn, TEntity>(name, new DeleteEntityFrameworkCoreArgs<TIn, TIn, TEntity>
// {
// InputStream = inputStream,
// Match = match,
// GetValue = i => i
// }).Output;
// }
// [Obsolete]
// public static IStream<Correlated<TIn>> EfCoreDelete<TIn, TEntity>(this IStream<Correlated<TIn>> inputStream, string name, Expression<Func<TIn, TEntity, bool>> match)
// where TEntity : class
// {
// return new DeleteEntityFrameworkCoreStreamNode<Correlated<TIn>, TIn, TEntity>(name, new DeleteEntityFrameworkCoreArgs<Correlated<TIn>, TIn, TEntity>
// {
// InputStream = inputStream,
// Match = match,
// GetValue = i => i.Row
// }).Output;
// }
public static IStream<TIn> EfCoreDelete<TIn, TEntity>(this IStream<TIn> inputStream, string name, Func<DeleteEntityFrameworkCoreArgsBuilder<TIn>, DeleteEntityFrameworkCoreArgsBuilder<TIn, TEntity>> builder)
where TEntity : class
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.EntityFrameworkCore</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand All @@ -27,8 +27,8 @@

<ItemGroup>
<PackageReference Include="FastMember" Version="1.5.0" allowedVersions="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" allowedVersions="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" allowedVersions="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.8" allowedVersions="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.8" allowedVersions="6.0.0" />
<PackageReference Include="system.data.sqlclient" Version="4.8.5" allowedVersions="4.8.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.ExcelFile/Paillave.Etl.ExcelFile.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.ExcelFile</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.ExecutionToolkit</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.FileSystem/Paillave.Etl.FileSystem.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.FileSystem</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.FromConfigurationConnectors</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.Ftp/Paillave.Etl.Ftp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.Ftp</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.GraphApi/Paillave.Etl.GraphApi.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.GraphApi</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.Mail/Paillave.Etl.Mail.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.Mail</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.Pdf/Paillave.Etl.Pdf.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.Pdf</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.Sftp/Paillave.Etl.Sftp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.Sftp</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.SqlServer/Paillave.Etl.SqlServer.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.SqlServer</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.TextFile/Paillave.Etl.TextFile.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.TextFile</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.XmlFile/Paillave.Etl.XmlFile.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.XmlFile</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.Zip/Paillave.Etl.Zip.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.Zip</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl/Paillave.Etl.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.Core</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Pdf/Paillave.Pdf.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.Pdf</PackageId>
<Version>2.1.14-beta</Version>
<Version>2.1.15-beta</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
4 changes: 2 additions & 2 deletions src/Tutorials/BlogTutorial/BlogTutorial.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.8" />
</ItemGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

<ItemGroup>
<PackageReference Include="Autofac" Version="7.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.8" />
</ItemGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Tutorials/Paillave.Etl.Samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static async Task Main4(string[] args)
{
using (var dbCtx = new TestDbContext())
{
await dbCtx.Set<Position>().DeleteWhereAsync(i => i.CompositionId == 10);
// await dbCtx.Set<Position>().DeleteWhereAsync(i => i.CompositionId == 10);
}
// var processRunner = StreamProcessRunner.Create<string[]>(Import);
// var res = await processRunner.ExecuteAsync(args);
Expand Down
4 changes: 2 additions & 2 deletions src/Tutorials/SimpleTutorial/SimpleTutorial.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.8" />
</ItemGroup>

<PropertyGroup>
Expand Down

0 comments on commit 7dd942f

Please sign in to comment.