|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace ReflectionStudio.Core.Database.Schema
{
public class SchemaUtility
{
// Methods
public static Type GetSystemType(DbType type)
{
switch (type)
{
case DbType.AnsiString:
return typeof(string);
case DbType.Binary:
return typeof(byte[]);
case DbType.Byte:
return typeof(byte);
case DbType.Boolean:
return typeof(bool);
case DbType.Currency:
return typeof(decimal);
case DbType.Date:
return typeof(DateTime);
case DbType.DateTime:
return typeof(DateTime);
case DbType.Decimal:
return typeof(decimal);
case DbType.Double:
return typeof(double);
case DbType.Guid:
return typeof(Guid);
case DbType.Int16:
return typeof(short);
case DbType.Int32:
return typeof(int);
case DbType.Int64:
return typeof(long);
case DbType.Object:
return typeof(object);
case DbType.SByte:
return typeof(sbyte);
case DbType.Single:
return typeof(float);
case DbType.String:
return typeof(string);
case DbType.Time:
return typeof(TimeSpan);
case DbType.UInt16:
return typeof(ushort);
case DbType.UInt32:
return typeof(uint);
case DbType.UInt64:
return typeof(ulong);
case DbType.VarNumeric:
return typeof(decimal);
case DbType.AnsiStringFixedLength:
return typeof(string);
case DbType.StringFixedLength:
return typeof(string);
}
return typeof(object);
}
public static Type GetSystemType(SqlDbType type)
{
switch (type)
{
case SqlDbType.BigInt:
return typeof(long);
case SqlDbType.Binary:
return typeof(byte[]);
case SqlDbType.Bit:
return typeof(bool);
case SqlDbType.Char:
return typeof(string);
case SqlDbType.DateTime:
return typeof(DateTime);
case SqlDbType.Decimal:
return typeof(decimal);
case SqlDbType.Float:
return typeof(double);
case SqlDbType.Image:
return typeof(byte[]);
case SqlDbType.Int:
return typeof(int);
case SqlDbType.Money:
return typeof(decimal);
case SqlDbType.NChar:
return typeof(string);
case SqlDbType.NText:
return typeof(string);
case SqlDbType.NVarChar:
return typeof(string);
case SqlDbType.Real:
return typeof(float);
case SqlDbType.UniqueIdentifier:
return typeof(Guid);
case SqlDbType.SmallDateTime:
return typeof(DateTime);
case SqlDbType.SmallInt:
return typeof(short);
case SqlDbType.SmallMoney:
return typeof(decimal);
case SqlDbType.Text:
return typeof(string);
case SqlDbType.Timestamp:
return typeof(DateTime);
case SqlDbType.TinyInt:
return typeof(byte);
case SqlDbType.VarBinary:
return typeof(byte[]);
case SqlDbType.VarChar:
return typeof(string);
case SqlDbType.Variant:
return typeof(object);
}
return typeof(object);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
WPF and MVVM fan, I practice C # in all its forms from the beginning of the NET Framework without mentioning C ++ / MFC and other software packages such as databases, ASP, WCF, Web & Windows services, Application, and now Core and UWP.
In my wasted hours, I am guilty of having fathered C.B.R. and its cousins C.B.R. for WinRT and UWP on the Windows store.
But apart from that, I am a great handyman ... the house, a rocket stove to heat the jacuzzi and the last one: a wood oven for pizza, bread, and everything that goes inside
https://guillaumewaser.wordpress.com/
https://fouretcompagnie.wordpress.com/