Skip to main content
1 of 3
BCdotWEB
  • 11.4k
  • 2
  • 28
  • 45

Don't do this:

    public DatabaseCommandInfo(string storeProcName, SqlParameter[] spParams)
    {
      StoredProcName = storeProcName;
      Parameters = spParams;
      CommandType = CommandType.StoredProcedure;
    }


    public DatabaseCommandInfo(string storeProcName, SqlParameter[] spParams, string[] tableNames)
    {
      StoredProcName = storeProcName;
      Parameters = spParams;
      TableNames = tableNames;
      Option = LoadOption.OverwriteChanges;
      CommandType = CommandType.StoredProcedure;
    }

Instead, use constructor chaining:

public DatabaseCommandInfo(string storeProcName, SqlParameter[] spParams)
    : this(storeProcName, spParams, new string[])
{
}

The same is true for ReadAsset:

public ReadAsset()
   : this(new DatabaseHelper("Data Source=.; Initial Catalog=Assets; integrated security=true;"))
{
}

The code isn't consistent: row[columnName] != DBNull.Value vs DBNull.Value.Equals(row[columnName]).


Why is this checked: row.Table.Columns.Count > 0 ?


In both GetValue and GetNullableValue you repeatedly call row[columnName]. Call it once and store the value in a variable and work with that variable.


In IdsToXml the element name "Ids" is used twice, so ideally it should be a const.


Your list of SqlParameter is missing the SqlDbType. I'd prefer this:

  var sqlParams = new[]
  {
    new SqlParameter("@TypeId", SqlDbType.Int).Value = request.TypeId,
BCdotWEB
  • 11.4k
  • 2
  • 28
  • 45