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>
/// Month list obtainment query
/// </summary>
/// <remarks>
/// Demonstration of imperative query building
/// </remarks>
public static class GetMonthList_Query
{
   public static List<Month_Item>
      EmptyResult => new List<Month_Item>();
   public static async Task<List<Month_Item>> PERFORM_A()
   {
      var list = await HDbQuery.PerformSelect_A<Month_Item>( "select * from [AUX:MonthList]()" );
      //list.Add( new Month_Item(){ NO = 13, Name = "!Thirteenth", NameGen = "!Тринадцатый" } );
      return list;
   }
} // GetMonthList_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 Month_Item: ResultSetItemBase
{
   public int NO = INT();
   public string Name = NS();
   public string NameGen = NS( "InGenitiveCase", true ); // treat null DB-data as empty string
   public Month_Item Month_Duplicate() =>
      (Month_Item)MemberwiseClone();
} // Month_Item
//--------------------------------------------------------------------------------------------------
} // MyFlat.DB
