//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// DataHelpers.SQL satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using u = user_rtx;

namespace DataHelpers.SQL {

//**************************************************************************************************
[h_db_orm_type]
public class HSPResultOut<TOutData,TListItem>
: HSPCommandResultOut<TOutData>
where TOutData: class
{
// public SPResultStateForm StateForm;
// public bool IsAvailable;
// public bool Success;
// [u.opt_value] public Guid Status;
// public string? OutMessage;
// public string ErrorMessage;
// [u.strict_result] public TOutData Output;
// [u.strict_result] public string OutMessageNN;
// VerifyAvailable();

   public bool HasList => _list != null;
   /// <exception cref="InvalidOperationException" />
   [u.strict_result]
   public List<TListItem> List =>
      GetList() ?? throw HSPResultError.OutputListUnavailable;

   public HSPResultOut()
   {}
   public HSPResultOut( HSPResultParameters resultParams,
                        TOutData? output,
                        List<TListItem>? list )
   : base( resultParams, output ) =>
      _list = list;
   public HSPResultOut( HSPResultOutN<TOutData,TListItem> result )
   : base( result ) =>
      _list = result.List;

   /// <exception cref="InvalidOperationException" />
   public List<TListItem>? GetList()
   {
      VerifyAvailable();
      return _list;
   }

   readonly List<TListItem>? _list;

} // HSPResultOut<TOutData,TListItem>
//**************************************************************************************************

//**************************************************************************************************
[h_db_orm_type]
public class HSPResultOutRV<TOutData,TListItem>
: HSPCommandResultOutRV<TOutData>
where TOutData: class
{
// public SPResultStateForm StateForm;
// public bool IsAvailable;
// public int RetValue;
// [u.opt_value] public Guid Status;
// public string? OutMessage;
// public string OutMessageAsError;
// [u.strict_result] public TOutData Output;
// [u.strict_result] public string OutMessageNN;
// VerifyAvailable();

   public bool HasList => _list != null;
   /// <exception cref="InvalidOperationException" />
   [u.strict_result]
   public List<TListItem> List =>
      GetList() ?? throw HSPResultError.OutputListUnavailable;

   public HSPResultOutRV()
   {}
   public HSPResultOutRV( HSPResultParameters resultParams,
                          TOutData? output,
                          List<TListItem>? list )
   : base( resultParams, output ) =>
      _list = list;
   public HSPResultOutRV( HSPResultOutRVN<TOutData,TListItem> result )
   : base( result ) =>
      _list = result.List;

   /// <exception cref="InvalidOperationException" />
   public List<TListItem>? GetList()
   {
      VerifyAvailable();
      return _list;
   }

   readonly List<TListItem>? _list;

} // HSPResultOutRV<TOutData,TListItem>
//**************************************************************************************************

} // DataHelpers.SQL
