//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// 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 HSPCommandResultOut<TOutData>: HSPCommandResult
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 string OutMessageNN;
// VerifyAvailable();

   public bool HasOutput => _output != null;
   /// <exception cref="InvalidOperationException" />
   [u.strict_result]
   public TOutData Output =>
      GetOutput() ?? throw HSPResultError.OutputDataUnavailable;

   public HSPCommandResultOut()
   {}
   public HSPCommandResultOut( HSPResultParameters resultParams,
                               TOutData? output )
   : base( resultParams ) =>
      _output = output;
   public HSPCommandResultOut( HSPCommandResultOutN<TOutData> result )
   : base( result.Success, result.Status, result.OutMessage ) =>
      _output = result.Output;

   /// <exception cref="InvalidOperationException" />
   public TOutData? GetOutput()
   {
      VerifyAvailable();
      return _output;
   }

   readonly TOutData? _output;

} // HSPCommandResultOut<TOutData>
//**************************************************************************************************

//**************************************************************************************************
[h_db_orm_type]
public class HSPCommandResultOutRV<TOutData>: HSPCommandResultRV
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 string OutMessageNN;
// VerifyAvailable();

   public bool HasOutput => _output != null;
   /// <exception cref="InvalidOperationException" />
   [u.strict_result]
   public TOutData Output =>
      GetOutput() ?? throw HSPResultError.OutputDataUnavailable;

   public HSPCommandResultOutRV()
   {}
   public HSPCommandResultOutRV( HSPResultParameters resultParams,
                                 TOutData? output )
   : base( resultParams ) =>
      _output =  output;
   public HSPCommandResultOutRV( HSPCommandResultOutRVN<TOutData> result )
   : base( result.RetValue, result.Status, result.OutMessage ) =>
      _output = result.Output;

   /// <exception cref="InvalidOperationException" />
   public TOutData? GetOutput()
   {
      VerifyAvailable();
      return _output;
   }

   readonly TOutData? _output;

} // HSPCommandResultOutRV<TOutData>
//**************************************************************************************************

} // DataHelpers.SQL
