25
25
using NHibernate . SqlTypes ;
26
26
using NUnit . Framework ;
27
27
28
- using AsyncTask = System . Threading . Tasks . Task ;
29
-
30
28
namespace NHibernate . Test . Insertordering
31
29
{
32
30
[ TestFixture ]
33
- public class InsertOrderingFixtureAsync : TestCase
31
+ public partial class InsertOrderingFixtureAsync : TestCase
34
32
{
35
33
const int batchSize = 10 ;
36
34
const int instancesPerEach = 12 ;
@@ -546,7 +544,7 @@ public async System.Threading.Tasks.Task WithUnidiOneToOneAsync()
546
544
547
545
#region Nested type: StatsBatcher
548
546
549
- public class StatsBatcher : SqlClientBatchingBatcher
547
+ public partial class StatsBatcher : SqlClientBatchingBatcher
550
548
{
551
549
private static string batchSQL ;
552
550
private static IList < int > batchSizes = new List < int > ( ) ;
@@ -569,18 +567,18 @@ public static void Reset()
569
567
batchSQL = null ;
570
568
}
571
569
572
- public override DbCommand PrepareBatchCommand ( CommandType type , SqlString sql , SqlType [ ] parameterTypes )
570
+ public override async System . Threading . Tasks . Task < DbCommand > PrepareBatchCommandAsync ( CommandType type , SqlString sql , SqlType [ ] parameterTypes , CancellationToken cancellationToken )
573
571
{
574
- var result = base . PrepareBatchCommand ( type , sql , parameterTypes ) ;
572
+ var result = await ( base . PrepareBatchCommandAsync ( type , sql , parameterTypes , cancellationToken ) ) ;
575
573
576
574
PrepareStats ( sql ) ;
577
575
578
576
return result ;
579
577
}
580
578
581
- public override Task < DbCommand > PrepareBatchCommandAsync ( CommandType type , SqlString sql , SqlType [ ] parameterTypes , CancellationToken cancellationToken )
579
+ public override DbCommand PrepareBatchCommand ( CommandType type , SqlString sql , SqlType [ ] parameterTypes )
582
580
{
583
- var result = base . PrepareBatchCommandAsync ( type , sql , parameterTypes , cancellationToken ) ;
581
+ var result = base . PrepareBatchCommand ( type , sql , parameterTypes ) ;
584
582
585
583
PrepareStats ( sql ) ;
586
584
@@ -603,16 +601,23 @@ private static void PrepareStats(SqlString sql)
603
601
}
604
602
}
605
603
606
- public override void AddToBatch ( IExpectation expectation )
604
+ public override System . Threading . Tasks . Task AddToBatchAsync ( IExpectation expectation , CancellationToken cancellationToken )
607
605
{
608
- AddStats ( ) ;
609
- base . AddToBatch ( expectation ) ;
606
+ try
607
+ {
608
+ AddStats ( ) ;
609
+ return base . AddToBatchAsync ( expectation , cancellationToken ) ;
610
+ }
611
+ catch ( Exception ex )
612
+ {
613
+ return System . Threading . Tasks . Task . FromException < object > ( ex ) ;
614
+ }
610
615
}
611
616
612
- public override AsyncTask AddToBatchAsync ( IExpectation expectation , CancellationToken cancellationToken )
617
+ public override void AddToBatch ( IExpectation expectation )
613
618
{
614
619
AddStats ( ) ;
615
- return base . AddToBatchAsync ( expectation , cancellationToken ) ;
620
+ base . AddToBatch ( expectation ) ;
616
621
}
617
622
618
623
private static void AddStats ( )
@@ -624,16 +629,23 @@ private static void AddStats()
624
629
Console . WriteLine ( "Adding to batch [" + batchSQL + "]" ) ;
625
630
}
626
631
627
- protected override void DoExecuteBatch ( DbCommand ps )
632
+ protected override System . Threading . Tasks . Task DoExecuteBatchAsync ( DbCommand ps , CancellationToken cancellationToken )
628
633
{
629
- ExecuteStats ( ) ;
630
- base . DoExecuteBatch ( ps ) ;
634
+ try
635
+ {
636
+ ExecuteStats ( ) ;
637
+ return base . DoExecuteBatchAsync ( ps , cancellationToken ) ;
638
+ }
639
+ catch ( Exception ex )
640
+ {
641
+ return System . Threading . Tasks . Task . FromException < object > ( ex ) ;
642
+ }
631
643
}
632
644
633
- protected override AsyncTask DoExecuteBatchAsync ( DbCommand ps , CancellationToken cancellationToken )
645
+ protected override void DoExecuteBatch ( DbCommand ps )
634
646
{
635
647
ExecuteStats ( ) ;
636
- return base . DoExecuteBatchAsync ( ps , cancellationToken ) ;
648
+ base . DoExecuteBatch ( ps ) ;
637
649
}
638
650
639
651
private static void ExecuteStats ( )
@@ -651,7 +663,7 @@ private static void ExecuteStats()
651
663
652
664
#region Nested type: StatsBatcherFactory
653
665
654
- public class StatsBatcherFactory : IBatcherFactory
666
+ public partial class StatsBatcherFactory : IBatcherFactory
655
667
{
656
668
#region IBatcherFactory Members
657
669
@@ -665,4 +677,66 @@ public IBatcher CreateBatcher(ConnectionManager connectionManager, IInterceptor
665
677
666
678
#endregion
667
679
}
680
+ /// <content>
681
+ /// Contains generated async methods
682
+ /// </content>
683
+ public partial class InsertOrderingFixture : TestCase
684
+ {
685
+
686
+
687
+
688
+
689
+
690
+
691
+
692
+
693
+
694
+
695
+
696
+
697
+
698
+ /// <content>
699
+ /// Contains generated async methods
700
+ /// </content>
701
+ public partial class StatsBatcher : SqlClientBatchingBatcher
702
+ {
703
+
704
+ public override async System . Threading . Tasks . Task < DbCommand > PrepareBatchCommandAsync ( CommandType type , SqlString sql , SqlType [ ] parameterTypes , CancellationToken cancellationToken )
705
+ {
706
+ var result = await ( base . PrepareBatchCommandAsync ( type , sql , parameterTypes , cancellationToken ) ) ;
707
+
708
+ PrepareStats ( sql ) ;
709
+
710
+ return result ;
711
+ }
712
+
713
+ public override System . Threading . Tasks . Task AddToBatchAsync ( IExpectation expectation , CancellationToken cancellationToken )
714
+ {
715
+ try
716
+ {
717
+ AddStats ( ) ;
718
+ return base . AddToBatchAsync ( expectation , cancellationToken ) ;
719
+ }
720
+ catch ( Exception ex )
721
+ {
722
+ return System . Threading . Tasks . Task . FromException < object > ( ex ) ;
723
+ }
724
+ }
725
+
726
+ protected override System . Threading . Tasks . Task DoExecuteBatchAsync ( DbCommand ps , CancellationToken cancellationToken )
727
+ {
728
+ try
729
+ {
730
+ ExecuteStats ( ) ;
731
+ return base . DoExecuteBatchAsync ( ps , cancellationToken ) ;
732
+ }
733
+ catch ( Exception ex )
734
+ {
735
+ return System . Threading . Tasks . Task . FromException < object > ( ex ) ;
736
+ }
737
+ }
738
+ }
739
+
740
+
741
+ }
668
742
}
0 commit comments