private static Type ParseColumnType(string input)
{
// For speed, put the most common types at the top.
if (input == null)
{
return null;
}
string lowerInput = input.ToLower();
if (lowerInput.Equals("string"))
{
return typeof (string);
}
if (lowerInput.Equals("int") || lowerInput.Equals("integer") || lowerInput.Equals("int32"))
{
return typeof (int);
}
if (lowerInput.Equals("long") || lowerInput.Equals("int64"))
{
return typeof (long);
}
if (lowerInput.Equals("double"))
{
return typeof (double);
}
if (lowerInput.Equals("date") || lowerInput.Equals("datetime"))
{
return typeof (DateTime);
}
if (lowerInput.Equals("bool") || lowerInput.Equals("boolean"))
{
return typeof (bool);
}
if (lowerInput.Equals("short") || lowerInput.Equals("int16"))
{
return typeof (short);
}
if (lowerInput.Equals("byte"))
{
return typeof (byte);
}
if (lowerInput.Equals("char"))
{
return typeof (char);
}
if (lowerInput.Equals("float"))
{
return typeof (float);
}
if (lowerInput.Equals("bytearray"))
{
return typeof (byte[]);
}
if (lowerInput.Equals("int?") || lowerInput.Equals("integer?") || lowerInput.Equals("int32?"))
{
return typeof(int?);
}
if (lowerInput.Equals("long?") || lowerInput.Equals("int64?"))
{
return typeof(long?);
}
if (lowerInput.Equals("double?"))
{
return typeof(double?);
}
if (lowerInput.Equals("date?") || lowerInput.Equals("datetime?"))
{
return typeof(DateTime?);
}
if (lowerInput.Equals("bool?") || lowerInput.Equals("boolean?"))
{
return typeof(bool?);
}
if (lowerInput.Equals("short?") || lowerInput.Equals("int16?"))
{
return typeof(short?);
}
if (lowerInput.Equals("byte?"))
{
return typeof(byte?);
}
if (lowerInput.Equals("char?"))
{
return typeof(char?);
}
if (lowerInput.Equals("float?"))
{
return typeof(float?);
}
Type colType = Type.GetType(input, false);
if (colType != null)
{
return colType;
}
throw new BadDaoConfigurationException("Type " + input + " does not parse either as a primitive or as a valid class type.");
}