removed code redundancies.

This commit is contained in:
kay.one 2013-07-26 22:02:25 -07:00
commit 9a24268ee7
24 changed files with 104 additions and 185 deletions

View file

@ -33,17 +33,14 @@ namespace Marr.Data.Converters
{
return true;
}
else if (val == 0)
if (val == 0)
{
return false;
}
else
{
throw new ConversionException(
string.Format(
throw new ConversionException(
string.Format(
"The BooleanCharConverter could not convert the value '{0}' to a boolean.",
dbValue));
}
}
public object ToDB(object clrValue)
@ -54,14 +51,11 @@ namespace Marr.Data.Converters
{
return 1;
}
else if (val == false)
if (val == false)
{
return 0;
}
else
{
return DBNull.Value;
}
return DBNull.Value;
}
public Type DbType

View file

@ -33,17 +33,14 @@ namespace Marr.Data.Converters
{
return true;
}
else if (val == "N")
if (val == "N")
{
return false;
}
else
{
throw new ConversionException(
string.Format(
throw new ConversionException(
string.Format(
"The BooleanYNConverter could not convert the value '{0}' to a boolean.",
dbValue));
}
}
public object ToDB(object clrValue)
@ -54,14 +51,11 @@ namespace Marr.Data.Converters
{
return "Y";
}
else if (val == false)
if (val == false)
{
return "N";
}
else
{
return DBNull.Value;
}
return DBNull.Value;
}
public Type DbType

View file

@ -24,16 +24,14 @@ namespace Marr.Data.Converters
{
if (dbValue == null || dbValue == DBNull.Value)
return null;
else
return Enum.ToObject(map.FieldType, (int)dbValue);
return Enum.ToObject(map.FieldType, (int)dbValue);
}
public object ToDB(object clrValue)
{
if (clrValue == null)
return DBNull.Value;
else
return (int)clrValue;
return (int)clrValue;
}
public Type DbType

View file

@ -24,16 +24,14 @@ namespace Marr.Data.Converters
{
if (dbValue == null || dbValue == DBNull.Value)
return null;
else
return Enum.Parse(map.FieldType, (string)dbValue);
return Enum.Parse(map.FieldType, (string)dbValue);
}
public object ToDB(object clrValue)
{
if (clrValue == null)
return DBNull.Value;
else
return clrValue.ToString();
return clrValue.ToString();
}
public Type DbType

View file

@ -65,10 +65,7 @@ namespace Marr.Data
{
return col.TryGetAltName();
}
else
{
return col.Name;
}
return col.Name;
}
/// <summary>

View file

@ -174,8 +174,7 @@ namespace Marr.Data
{
if (string.IsNullOrEmpty(sql))
throw new ArgumentNullException("sql", "A SQL query or stored procedure name is required");
else
Command.CommandText = sql;
Command.CommandText = sql;
try
{
@ -197,8 +196,7 @@ namespace Marr.Data
{
if (string.IsNullOrEmpty(sql))
throw new ArgumentNullException("sql", "A SQL query or stored procedure name is required");
else
Command.CommandText = sql;
Command.CommandText = sql;
try
{
@ -223,8 +221,7 @@ namespace Marr.Data
{
if (string.IsNullOrEmpty(sql))
throw new ArgumentNullException("sql", "A SQL query or stored procedure name is required");
else
Command.CommandText = sql;
Command.CommandText = sql;
try
{

View file

@ -105,11 +105,8 @@ namespace Marr.Data
// Return entity specific column map strategy
return _columnMapStrategies[entityType];
}
else
{
// Return the default column map strategy
return _columnMapStrategies[typeof(object)];
}
// Return the default column map strategy
return _columnMapStrategies[typeof(object)];
}
#endregion
@ -219,21 +216,18 @@ namespace Marr.Data
// User registered type converter
return TypeConverters[dataType];
}
else if (TypeConverters.ContainsKey(typeof(Enum)) && dataType.IsEnum)
if (TypeConverters.ContainsKey(typeof(Enum)) && dataType.IsEnum)
{
// A converter is registered to handled enums
return TypeConverters[typeof(Enum)];
}
else if (TypeConverters.ContainsKey(typeof(object)))
if (TypeConverters.ContainsKey(typeof(object)))
{
// User registered default converter
return TypeConverters[typeof(object)];
}
else
{
// No conversion
return null;
}
// No conversion
return null;
}
#endregion

View file

@ -109,10 +109,7 @@ namespace Marr.Data.Mapping
{
return AltName;
}
else
{
return Name;
}
return Name;
}
}
}

View file

@ -26,10 +26,7 @@ namespace Marr.Data.Mapping
{
return AltName;
}
else
{
return Name;
}
return Name;
}
}
}

View file

@ -216,10 +216,7 @@ namespace Marr.Data.Mapping
fieldName,
typeof(TEntity).Name));
}
else
{
MappedColumns.Add(columnMap);
}
MappedColumns.Add(columnMap);
}
/// <summary>

View file

@ -153,10 +153,7 @@ namespace Marr.Data.Mapping
fieldName,
typeof(TEntity).Name));
}
else
{
Relationships.Add(relationship);
}
Relationships.Add(relationship);
}
/// <summary>

View file

@ -67,10 +67,7 @@ namespace Marr.Data.Mapping.Strategies
{
return (atts[0] as TableAttribute).Name;
}
else
{
return entityType.Name;
}
return entityType.Name;
}
/// <summary>

View file

@ -25,41 +25,40 @@ namespace Marr.Data.Parameters
if (type == typeof(String))
return DbType.String;
else if (type == typeof(Int32))
if (type == typeof(Int32))
return DbType.Int32;
else if (type == typeof(Decimal))
if (type == typeof(Decimal))
return DbType.Decimal;
else if (type == typeof(DateTime))
if (type == typeof(DateTime))
return DbType.DateTime;
else if (type == typeof(Boolean))
if (type == typeof(Boolean))
return DbType.Boolean;
else if (type == typeof(Int16))
if (type == typeof(Int16))
return DbType.Int16;
else if (type == typeof(Single))
if (type == typeof(Single))
return DbType.Single;
else if (type == typeof(Int64))
if (type == typeof(Int64))
return DbType.Int64;
else if (type == typeof(Double))
if (type == typeof(Double))
return DbType.Double;
else if (type == typeof(Byte))
if (type == typeof(Byte))
return DbType.Byte;
else if (type == typeof(Byte[]))
if (type == typeof(Byte[]))
return DbType.Binary;
else if (type == typeof(Guid))
if (type == typeof(Guid))
return DbType.Guid;
else
return DbType.Object;
return DbType.Object;
}
public void SetDbType(IDbDataParameter param, Enum dbType)

View file

@ -26,38 +26,37 @@ namespace Marr.Data.Parameters
if (type == typeof(String))
return OleDbType.VarChar;
else if (type == typeof(Int32))
if (type == typeof(Int32))
return OleDbType.Integer;
else if (type == typeof(Decimal))
if (type == typeof(Decimal))
return OleDbType.Decimal;
else if (type == typeof(DateTime))
if (type == typeof(DateTime))
return OleDbType.DBTimeStamp;
else if (type == typeof(Boolean))
if (type == typeof(Boolean))
return OleDbType.Boolean;
else if (type == typeof(Int16))
if (type == typeof(Int16))
return OleDbType.SmallInt;
else if (type == typeof(Int64))
if (type == typeof(Int64))
return OleDbType.BigInt;
else if (type == typeof(Double))
if (type == typeof(Double))
return OleDbType.Double;
else if (type == typeof(Byte))
if (type == typeof(Byte))
return OleDbType.Binary;
else if (type == typeof(Byte[]))
if (type == typeof(Byte[]))
return OleDbType.VarBinary;
else if (type == typeof(Guid))
if (type == typeof(Guid))
return OleDbType.Guid;
else
return OleDbType.Variant;
return OleDbType.Variant;
}
public void SetDbType(IDbDataParameter param, Enum dbType)

View file

@ -26,41 +26,40 @@ namespace Marr.Data.Parameters
if (type == typeof(String))
return SqlDbType.VarChar;
else if (type == typeof(Int32))
if (type == typeof(Int32))
return SqlDbType.Int;
else if (type == typeof(Decimal))
if (type == typeof(Decimal))
return SqlDbType.Decimal;
else if (type == typeof(DateTime))
if (type == typeof(DateTime))
return SqlDbType.DateTime;
else if (type == typeof(Boolean))
if (type == typeof(Boolean))
return SqlDbType.Bit;
else if (type == typeof(Int16))
if (type == typeof(Int16))
return SqlDbType.SmallInt;
else if (type == typeof(Int64))
if (type == typeof(Int64))
return SqlDbType.BigInt;
else if (type == typeof(Double))
if (type == typeof(Double))
return SqlDbType.Float;
else if (type == typeof(Char))
if (type == typeof(Char))
return SqlDbType.Char;
else if (type == typeof(Byte))
if (type == typeof(Byte))
return SqlDbType.Binary;
else if (type == typeof(Byte[]))
if (type == typeof(Byte[]))
return SqlDbType.VarBinary;
else if (type == typeof(Guid))
if (type == typeof(Guid))
return SqlDbType.UniqueIdentifier;
else
return SqlDbType.Variant;
return SqlDbType.Variant;
}
public void SetDbType(IDbDataParameter param, Enum dbType)

View file

@ -32,10 +32,7 @@ namespace Marr.Data.QGen
{
return ComplexPaging();
}
else
{
return SimplePaging();
}
return SimplePaging();
}
/// <summary>

View file

@ -18,10 +18,7 @@ namespace Marr.Data.QGen
{
return ComplexRowCount();
}
else
{
return SimpleRowCount();
}
return SimpleRowCount();
}
/// <summary>

View file

@ -95,10 +95,7 @@ namespace Marr.Data.QGen
{
return columnInfo.AltName;
}
else
{
return columnInfo.Name;
}
return columnInfo.Name;
}
public void BuildFromClause(StringBuilder sql)

View file

@ -32,10 +32,7 @@ namespace Marr.Data.QGen
{
return ComplexPaging();
}
else
{
return SimplePaging();
}
return SimplePaging();
}
private string SimplePaging()

View file

@ -281,10 +281,7 @@ namespace Marr.Data.QGen
{
return _sb.ToString();
}
else
{
return _constantWhereClause;
}
return _constantWhereClause;
}
}

View file

@ -32,14 +32,11 @@ namespace Marr.Data.Reflection
{
return null;
}
else if (fieldType.IsValueType)
if (fieldType.IsValueType)
{
return Activator.CreateInstance(fieldType);
}
else
{
return null;
}
return null;
}
/// <summary>