I'm sitting down to write a massive switch() statement to turn SQL datatypes into CLR datatypes in order to generate classes from MSSQL stored procedures. I'm using this chart as a reference. Before I get too far into what will probably take all day and be a huge pain to fully test, I'd like to call out to the SO community to see if anyone else has already written or found something in C# to accomplish this seemingly common and assuredly tedious task.
C+, C, C- indicates satisfactory performance. D+, D, D- indicates less than satisfactory performance. F indicates unsatisfactory performance (no credit: always include last date of attendance).
If you receive one C during your high school years, it may ultimately affect your chances of getting into a top school. However, it won't automatically exclude you from one. Instead, it will make earning an acceptance a little harder for you, as you'll have to compensate in other areas.
Most students (and most parents) don't realize that in college, a C is a great grade. When the student who pulled a 4.0 in high school ends up with a 2.5 GPA in their first semester in college, their shock is real.
A passing grade is considered to be a C or above.
This is the one we use. You may want to tweak it (e.g. nullable/non-nullable types etc.) but it should save you most of the typing.
public static Type GetClrType(SqlDbType sqlType) { switch (sqlType) { case SqlDbType.BigInt: return typeof(long?); case SqlDbType.Binary: case SqlDbType.Image: case SqlDbType.Timestamp: case SqlDbType.VarBinary: return typeof(byte[]); case SqlDbType.Bit: return typeof(bool?); case SqlDbType.Char: case SqlDbType.NChar: case SqlDbType.NText: case SqlDbType.NVarChar: case SqlDbType.Text: case SqlDbType.VarChar: case SqlDbType.Xml: return typeof(string); case SqlDbType.DateTime: case SqlDbType.SmallDateTime: case SqlDbType.Date: case SqlDbType.Time: case SqlDbType.DateTime2: return typeof(DateTime?); case SqlDbType.Decimal: case SqlDbType.Money: case SqlDbType.SmallMoney: return typeof(decimal?); case SqlDbType.Float: return typeof(double?); case SqlDbType.Int: return typeof(int?); case SqlDbType.Real: return typeof(float?); case SqlDbType.UniqueIdentifier: return typeof(Guid?); case SqlDbType.SmallInt: return typeof(short?); case SqlDbType.TinyInt: return typeof(byte?); case SqlDbType.Variant: case SqlDbType.Udt: return typeof(object); case SqlDbType.Structured: return typeof(DataTable); case SqlDbType.DateTimeOffset: return typeof(DateTimeOffset?); default: throw new ArgumentOutOfRangeException("sqlType"); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With