I am trying to reorganize some code here that was made earlier by other guys, as I find it quite impractical Here is an example
protected void SetParameterValue(SqlParameter parameter, string parameterValue, bool isNullable)
{
if ((null == parameterValue || parameterValue == NULL_STRING) && isNullable)
parameter.Value = DBNull.Value;
else parameter.Value = parameterValue;
}
protected void SetParameterValue(SqlParameter parameter, int parameterValue, bool isNullable)
{
if (parameterValue == NULL_INT && isNullable)
parameter.Value = DBNull.Value;
else parameter.Value = parameterValue;
}
protected void SetParameterValue( SqlParameter parameter, Int64 parameterValue, bool isNullable)
{
if (parameterValue == NULL_LONG && isNullable)
parameter.Value = DBNull.Value;
else parameter.Value = parameterValue;
}
Like these, there are many more. Now I needed to create one that accepts a new type (which does not yet have a method for it), and decided that maybe I can clean it up a bit, make it better. my idea is to create something like
protected void SetParameterValue<T>(SqlParameter parameter, T parameterValue, bool isNullable)
however, I do not know what the best approach is, what I can encapsulate inside this general method and what I need to do in separate methods. Is it worth it? or is the "many methods" approach okay? What will I get from the total? thank!