//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// 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,[HOptional] object? value)
{
   HArgChecking.VerifyNotNull( paramName );
   return new SqlParameter(){
      ParameterName = paramName,
      Direction = ParameterDirection.Input,
      IsNullable = true,
      Value = value };
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter NullableInOut(string paramName,[HOptional] object? value)
{
   HArgChecking.VerifyNotNull( paramName );
   return new SqlParameter(){
      ParameterName = paramName,
      Direction = ParameterDirection.InputOutput,
      IsNullable = true,
      Value = value };
}
public static SqlParameter NullableRetValue() =>
   new SqlParameter(){
      Direction = ParameterDirection.ReturnValue,
      IsNullable = true };

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

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

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

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

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

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

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

} // CommonHelpers
