//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Reflection;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace CommonHelpers {

//**************************************************************************************************
[HDbOrmType]
public static class HDbQueryPerformer {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="ArgumentNullException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
public static async Task<List<TListItem>>
   Do_A<TListItem>( HAsyncDbQueryRoutine<TListItem> bodyA ) =>
      await HDbAccessPerformer.Do_A<List<TListItem>>(async()=>{
         var list = await HArgChecking.NN( bodyA )().ConfigureAwait(false);
         return HDbQuery.VerifyRSet( list );
      }).ConfigureAwait(false);

/// <exception cref="ArgumentNullException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
public static async Task<( List<TList1_Item> List_1,
                           List<TList2_Item> List_2 )>
   Do_A<TList1_Item,TList2_Item>(
      HAsyncDbQueryRoutine_2<TList1_Item,TList2_Item> bodyA ) =>
         await HDbAccessPerformer.Do_A<(List<TList1_Item>,List<TList2_Item>)>(
            async()=>{
               var t = await HArgChecking.NN( bodyA )().ConfigureAwait(false);
               return ( VerifyRSet_1( t.List_1 ), VerifyRSet_2( t.List_2 ) );
            }).ConfigureAwait(false);

/// <exception cref="ArgumentNullException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
public static async Task<( List<TList1_Item> List_1,
                           List<TList2_Item> List_2,
                           List<TList3_Item> List_3 )>
   Do_A<TList1_Item,TList2_Item,TList3_Item>(
      HAsyncDbQueryRoutine_3<TList1_Item,TList2_Item,TList3_Item> bodyA ) =>
         await HDbAccessPerformer.Do_A<(List<TList1_Item>,List<TList2_Item>,List<TList3_Item>)>(
            async()=>{
               var t = await HArgChecking.NN( bodyA )().ConfigureAwait(false);
               return ( VerifyRSet_1( t.List_1 ), VerifyRSet_2( t.List_2 ),
                        VerifyRSet_3( t.List_3 ) );
            }).ConfigureAwait(false);

/// <exception cref="ArgumentNullException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
public static async Task<( List<TList1_Item> List_1,
                           List<TList2_Item> List_2,
                           List<TList3_Item> List_3,
                           List<TList4_Item> List_4 )>
   Do_A<TList1_Item,TList2_Item,TList3_Item,TList4_Item>(
      HAsyncDbQueryRoutine_4<TList1_Item,TList2_Item,TList3_Item,TList4_Item> bodyA ) =>
         await HDbAccessPerformer.Do_A<(List<TList1_Item>,List<TList2_Item>,List<TList3_Item>,
                                       List<TList4_Item>)>(
            async()=>{
               var t = await HArgChecking.NN( bodyA )().ConfigureAwait(false);
               return ( VerifyRSet_1( t.List_1 ), VerifyRSet_2( t.List_2 ),
                        VerifyRSet_3( t.List_3 ), VerifyRSet_4( t.List_4 ) );
            }).ConfigureAwait(false);

/// <exception cref="ArgumentNullException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
public static async Task<( List<TList1_Item> List_1,
                           List<TList2_Item> List_2,
                           List<TList3_Item> List_3,
                           List<TList4_Item> List_4,
                           List<TList5_Item> List_5 )>
   Do_A<TList1_Item,TList2_Item,TList3_Item,TList4_Item,TList5_Item>(
      HAsyncDbQueryRoutine_5<TList1_Item,TList2_Item,TList3_Item,TList4_Item,TList5_Item> bodyA ) =>
         await HDbAccessPerformer.Do_A<(List<TList1_Item>,List<TList2_Item>,List<TList3_Item>,
                                        List<TList4_Item>,List<TList5_Item>)>(
            async()=>{
               var t = await HArgChecking.NN( bodyA )().ConfigureAwait(false);
               return ( VerifyRSet_1( t.List_1 ), VerifyRSet_2( t.List_2 ),
                        VerifyRSet_3( t.List_3 ), VerifyRSet_4( t.List_4 ),
                        VerifyRSet_5( t.List_5 ) );
            }).ConfigureAwait(false);

//==================================================================================================

[HAsyncStatic]
static List<RSet_Item> VerifyRSet<RSet_Item>( List<RSet_Item>? list, int resultSetNo ) =>
   HDbQuery.VerifyRSet( list, resultSetNo );
[HAsyncStatic]
static List<RSet_Item> VerifyRSet_1<RSet_Item>( List<RSet_Item>? list ) => VerifyRSet( list, 1 );
[HAsyncStatic]
static List<RSet_Item> VerifyRSet_2<RSet_Item>( List<RSet_Item>? list ) => VerifyRSet( list, 2 );
[HAsyncStatic]
static List<RSet_Item> VerifyRSet_3<RSet_Item>( List<RSet_Item>? list ) => VerifyRSet( list, 3 );
[HAsyncStatic]
static List<RSet_Item> VerifyRSet_4<RSet_Item>( List<RSet_Item>? list ) => VerifyRSet( list, 4 );
[HAsyncStatic]
static List<RSet_Item> VerifyRSet_5<RSet_Item>( List<RSet_Item>? list ) => VerifyRSet( list, 5 );

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HDbQueryPerformer
//**************************************************************************************************

} // CommonHelpers
