One concern I have is I don’t want to bastardize SqlObjectDatabase by littering it with a bunch of if (connectionType == ConnectionType.DATABASE_MYSQL) do this, if (connectionType == ConnectionType.DATABASE_SQLSERVER) do that like the old way. It looks like a lot of that mess was cleaned up. I noticed this was everywhere in the old version so I wasn’t too concerned. However, now it’s been cleaned up, do you guys have any recommendations for keeping it clean? Because unfortunately, the only way around something like this is to check the connection type and fire off a completely new block, eg:
- Code: Select all
var command = string.Format("UPDATE `{0}` SET {1} WHERE {2}", tableHandler.TableName, string.Join(", ", columns.Select(col => string.Format("{0} = {1}", col.ColumnName, col.ParamName))), string.Join(" AND ", primary.Select(col => string.Format("{0} = {1}", col.ColumnName, col.ParamName))));
- Code: Select all
var command = string.Empty; if(connectionType == ConnectionType.DATABASE_MYSQL || connectionType == ConnectionType.DATABASE_SQLITE)) { command = string.Format("UPDATE `{0}` SET {1} WHERE {2}", tableHandler.TableName, string.Join(", ", columns.Select(col => string.Format("{0} = {1}", col.ColumnName, col.ParamName))), string.Join(" AND ", primary.Select(col => string.Format("{0} = {1}", col.ColumnName, col.ParamName)))); } else { command = string.Format("UPDATE {0} SET {1} WHERE {2}", tableHandler.TableName, string.Join(", ", columns.Select(col => string.Format("{0} = {1}", col.ColumnName, col.ParamName))), string.Join(" AND ", primary.Select(col => string.Format("{0} = {1}", col.ColumnName, col.ParamName)))); }