//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// 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, SqlDbType dbType, object? value ) =>
   new SqlParameter(){
      ParameterName = paramName,
      SqlDbType = dbType,
      Direction = ParameterDirection.Input,
      IsNullable = true,
      Value = value };

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

} // DataHelpers.SQL
