using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using CommonHelpers; // H…-types from DotNetHelpers library (with some DB-support + simple “ORM”)
using MyFlat.Base; // common types for MyFlat application (base exceptions etc.)

namespace MyFlat.DB {
//--------------------------------------------------------------------------------------------------
/// <summary>
/// Query for obtainment of certain quantity of Roman numbers
/// </summary>
/// <remarks>
/// Demonstration of imperative query building
/// </remarks>
public static class GetRomanNumbers_Query
{
   public static List<RomanNumber_Item>
      EmptyResult => new List<RomanNumber_Item>();
//*
   public static Task<List<RomanNumber_Item>> PERFORM_A( int count = -1 ) =>
   // Query with involvement of standard ADO parameters (“@ParameterName”):
      HDbQuery.PerformSelect_A<RomanNumber_Item>(
         "select * from [AUX:RomanNumbers]() where @Number < 0 or [Number] <= @Number",
         HSqlParam.In( "Number", count ) );
//*/
/*
   public static Task<List<RomanNumber_Item>> PERFORM_A( int count = -1 ) =>
   // Query, dependent on parameter — through dynamic string (via C# string interpolation):
      HDbQuery.PerformSelect_A<RomanNumber_Item>(
         "select * from [AUX:RomanNumbers]()" +
         (count>=0 ? $" where [Number]<={count}" : "") );
*/
/*
   public static Task<List<RomanNumber_Item>> PERFORM_A( int count = -1 ) =>
   // Query with preudo-parameter, through string formatting:
      HDbQuery.PerformSelectFmt_A<RomanNumber_Item>(
         "select * from [AUX:RomanNumbers]() " +
         "where {0} < 0 or [Number] <= {0}", count );
*/
} // GetRomanNumbers_Query
//--------------------------------------------------------------------------------------------------
/// <summary>
/// Result-set structure and record filling from corresponding asynchronous context (async.thread)
/// </summary>
/// <remarks>
/// Outside data-set reading context (related to async.thread) field accessors return default values.
/// </remarks>
public class RomanNumber_Item: ResultSetItemBase
{
   public int Number = INT();
   public string Inscription = NS( "Display" );
   public RomanNumber_Item RomanNumber_Duplicate() =>
      (RomanNumber_Item)MemberwiseClone();
} // RomanNumber_Item
//--------------------------------------------------------------------------------------------------
} // MyFlat.DB
