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

namespace DataHelpers.SQL {

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

public static SqlParameter NullableIn( string paramName, object? value ) =>
   new SqlParameter(){
      ParameterName = paramName,
      Direction = ParameterDirection.Input,
      IsNullable = true,
      Value = value };

public static SqlParameter NullableInOut( string paramName, object? value ) =>
   new SqlParameter(){
      ParameterName = paramName,
      Direction = ParameterDirection.InputOutput,
      IsNullable = true,
      Value = value };

public static SqlParameter NullableRetValue() =>
   new SqlParameter(){
      Direction = ParameterDirection.ReturnValue,
      IsNullable = true };

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

public static SqlParameter NullableIn( string paramName, DbType dbType, object? value ) =>
   new SqlParameter(){
      ParameterName = paramName,
      DbType = dbType,
      Direction = ParameterDirection.Input,
      IsNullable = true,
      Value = value };

public static SqlParameter NullableOut( string paramName, DbType dbType ) =>
   new SqlParameter(){
      ParameterName = paramName,
      DbType = dbType,
      Direction = ParameterDirection.Output,
      IsNullable = true };

public static SqlParameter NullableInOut( string paramName, DbType dbType, object? value ) =>
   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 };

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

public static SqlParameter AddNullableIn( SqlCommand command,
                                          string paramName, object? value ) =>
   command.Parameters.Add( NullableIn( paramName, value ) );

public static SqlParameter AddNullableInOut( SqlCommand command,
                                             string paramName, object? value ) =>
   command.Parameters.Add( NullableInOut( paramName, value ) );

public static SqlParameter AddNullableRetValue( SqlCommand command ) =>
   command.Parameters.Add( NullableRetValue() );

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

public static SqlParameter AddNullableIn( SqlCommand command, string paramName,
                                          DbType dbType, object? value ) =>
   command.Parameters.Add( NullableIn( paramName, dbType, value ) );

public static SqlParameter AddNullableOut( SqlCommand command, string paramName, DbType dbType ) =>
   command.Parameters.Add( NullableOut( paramName, dbType ) );

public static SqlParameter AddNullableInOut( SqlCommand command, string paramName,
                                             DbType dbType, object? value ) =>
   command.Parameters.Add( NullableInOut( paramName, dbType, value ) );

public static SqlParameter AddNullableRetValue( SqlCommand command, DbType dbType ) =>
   command.Parameters.Add( NullableRetValue( dbType ) );

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

} // DataHelpers.SQL
