Monday, March 9, 2020

C# - How call stored proc with output/return parameter ?

public static string GetStatistics() {
  string value = "";

  SqlCommand command = DB.SPPrepare( "GetStatisticsAsString" );
            
  command.Parameters.Add( new SqlParameter( "@catalog", "HYG" ) );
  command.Parameters.Add( new SqlParameter( "@catalogDSO", "MYDSO" ) );
  SqlParameter par = new SqlParameter( "@output", System.Data.SqlDbType.NVarChar, 2048 );
  par.Direction = System.Data.ParameterDirection.Output;
  command.Parameters.Add( par );

  command.ExecuteNonQuery();

  value = (string)command.Parameters[ "@output" ].Value;

  return value;
}

Monday, March 2, 2020

C# - How to use generic Min(), Max()

shape.Saved_Width =
 Math.Abs( shape.Points.Max( item => item.Draw_X )-shape.Points.Min( item => item.Draw_X ) );