@@ -778,6 +778,100 @@ public ValueTask<int> DeleteObjectsAsync<T>(string partition = null, FilterBuild
778
778
filter . Build ( commandBuilder , _jsonSerializer ) ;
779
779
}
780
780
781
+ #pragma warning disable CA2100 // Review SQL queries for security vulnerabilities
782
+ deleteCommand . CommandText = commandBuilder . ToString ( ) ;
783
+ #pragma warning restore CA2100 // Review SQL queries for security vulnerabilities
784
+
785
+ var deletionCount = deleteCommand . ExecuteNonQuery ( ) ;
786
+
787
+ transaction ? . Commit ( ) ;
788
+
789
+ return deletionCount ;
790
+ }
791
+ catch ( Exception ex )
792
+ {
793
+ transaction ? . Rollback ( ) ;
794
+ throw new TychoException ( "Failed to delete objects" , ex ) ;
795
+ }
796
+ finally
797
+ {
798
+ transaction ? . Dispose ( ) ;
799
+ }
800
+ } ,
801
+ _persistConnection ,
802
+ cancellationToken ) ;
803
+ }
804
+
805
+ public ValueTask < int > DeleteObjectsAsync ( string partition , bool withTransaction = true , CancellationToken cancellationToken = default )
806
+ {
807
+ return _connection
808
+ . WithConnectionBlockAsync (
809
+ _rateLimiter ,
810
+ conn =>
811
+ {
812
+ SqliteTransaction transaction = null ;
813
+
814
+ if ( withTransaction )
815
+ {
816
+ transaction = conn . BeginTransaction ( IsolationLevel . Serializable ) ;
817
+ }
818
+
819
+ try
820
+ {
821
+ using var deleteCommand = conn . CreateCommand ( ) ;
822
+
823
+ var commandBuilder = ReusableStringBuilder ;
824
+
825
+ commandBuilder . Append ( Queries . DeleteDataFromJsonValueWithPartition ) ;
826
+
827
+ deleteCommand . Parameters . Add ( ParameterPartition , SqliteType . Text ) . Value = partition . AsValueOrEmptyString ( ) ;
828
+
829
+ #pragma warning disable CA2100 // Review SQL queries for security vulnerabilities
830
+ deleteCommand . CommandText = commandBuilder . ToString ( ) ;
831
+ #pragma warning restore CA2100 // Review SQL queries for security vulnerabilities
832
+
833
+ var deletionCount = deleteCommand . ExecuteNonQuery ( ) ;
834
+
835
+ transaction ? . Commit ( ) ;
836
+
837
+ return deletionCount ;
838
+ }
839
+ catch ( Exception ex )
840
+ {
841
+ transaction ? . Rollback ( ) ;
842
+ throw new TychoException ( "Failed to delete objects" , ex ) ;
843
+ }
844
+ finally
845
+ {
846
+ transaction ? . Dispose ( ) ;
847
+ }
848
+ } ,
849
+ _persistConnection ,
850
+ cancellationToken ) ;
851
+ }
852
+
853
+ public ValueTask < int > DeleteObjectsAsync ( bool withTransaction = true , CancellationToken cancellationToken = default )
854
+ {
855
+ return _connection
856
+ . WithConnectionBlockAsync (
857
+ _rateLimiter ,
858
+ conn =>
859
+ {
860
+ SqliteTransaction transaction = null ;
861
+
862
+ if ( withTransaction )
863
+ {
864
+ transaction = conn . BeginTransaction ( IsolationLevel . Serializable ) ;
865
+ }
866
+
867
+ try
868
+ {
869
+ using var deleteCommand = conn . CreateCommand ( ) ;
870
+
871
+ var commandBuilder = ReusableStringBuilder ;
872
+
873
+ commandBuilder . Append ( Queries . DeleteDataFromJsonValue ) ;
874
+
781
875
#pragma warning disable CA2100 // Review SQL queries for security vulnerabilities
782
876
deleteCommand . CommandText = commandBuilder . ToString ( ) ;
783
877
#pragma warning restore CA2100 // Review SQL queries for security vulnerabilities
0 commit comments