//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace CommonHelpers {

//**************************************************************************************************
partial class HSqlParam {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="ArgumentNullException" />
public static SqlParameter NullableIn(string paramName,SqlDbType dbType,[HOptional] object? value)
{
   HArgChecking.VerifyNotNull( paramName );
   return new SqlParameter(){
      ParameterName = paramName,
      SqlDbType = dbType,
      Direction = ParameterDirection.Input,
      IsNullable = true,
      Value = value };
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter NullableOut(string paramName,SqlDbType dbType)
{
   HArgChecking.VerifyNotNull( paramName );
   return new SqlParameter(){
      ParameterName = paramName,
      SqlDbType = dbType,
      Direction = ParameterDirection.Output,
      IsNullable = true };
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter NullableInOut( string paramName, SqlDbType dbType,
                                          [HOptional] object? value )
{
   HArgChecking.VerifyNotNull( paramName );
   return new SqlParameter( paramName, value ){
      SqlDbType = dbType,
      Direction = ParameterDirection.InputOutput,
      IsNullable = true,
      Value = value };
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter NullableRetValue(SqlDbType dbType) =>
   new SqlParameter(){
      SqlDbType = dbType,
      Direction = ParameterDirection.ReturnValue,
      IsNullable = true };

//--------------------------------------------------------------------------------------------------

/// <exception cref="ArgumentNullException" />
public static SqlParameter NullableIn( string paramName, SqlDbType dbType, int size,
                                       [HOptional] object? value )
{
   HArgChecking.VerifyNotNull( paramName );
   return new SqlParameter(){
      ParameterName = paramName,
      SqlDbType = dbType,
      Size = size,
      Direction = ParameterDirection.Input,
      IsNullable = true,
      Value = value };
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter NullableOut(string paramName,SqlDbType dbType,int size)
{
   HArgChecking.VerifyNotNull( paramName );
   return new SqlParameter(){
      ParameterName = paramName,
      SqlDbType = dbType,
      Size = size,
      Direction = ParameterDirection.Output,
      IsNullable = true };
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter NullableInOut( string paramName, SqlDbType dbType, int size,
                                          [HOptional] object? value )
{
   HArgChecking.VerifyNotNull( paramName );
   return new SqlParameter( paramName, value ){
      SqlDbType = dbType,
      Size = size,
      Direction = ParameterDirection.InputOutput,
      IsNullable = true,
      Value = value };
}
public static SqlParameter NullableRetValue(SqlDbType dbType,int size) =>
   new SqlParameter(){
      SqlDbType = dbType,
      Size = size,
      Direction = ParameterDirection.ReturnValue,
      IsNullable = true };

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

/// <exception cref="ArgumentNullException" />
public static SqlParameter AddNullableIn( SqlCommand command, string paramName,
                                          SqlDbType dbType, [HOptional] object? value )
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( NullableIn( paramName, dbType, value ) );
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter AddNullableOut(SqlCommand command,string paramName,SqlDbType dbType)
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( NullableOut( paramName, dbType ) );
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter AddNullableInOut( SqlCommand command, string paramName,
                                             SqlDbType dbType, [HOptional] object? value )
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( NullableInOut( paramName, dbType, value ) );
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter AddNullableRetValue(SqlCommand command,SqlDbType dbType)
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( NullableRetValue( dbType ) );
}

//--------------------------------------------------------------------------------------------------

/// <exception cref="ArgumentNullException" />
public static SqlParameter AddNullableIn( SqlCommand command, string paramName,
                                          SqlDbType dbType, int size, [HOptional] object? value )
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( NullableIn( paramName, dbType, size, value ) );
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter AddNullableOut( SqlCommand command, string paramName,
                                           SqlDbType dbType, int size )
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( NullableOut( paramName, dbType, size ) );
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter AddNullableInOut( SqlCommand command, string paramName,
                                             SqlDbType dbType, int size, [HOptional] object? value )
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( NullableInOut( paramName, dbType, size, value ) );
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter AddNullableRetValue(SqlCommand command,SqlDbType dbType,int size)
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( NullableRetValue( dbType, size ) );
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HSqlParam
//**************************************************************************************************

} // CommonHelpers
