Hyena.Data.Sqlite.SqliteUtils.GetType C# (CSharp) Méthode

GetType() public static méthode

public static GetType ( Type type ) : string
type System.Type
Résultat string
        public static string GetType(Type type)
        {
            if (type == typeof (string)) {
                return "TEXT";
            } else if (type == typeof (int) || type == typeof (long) || type == typeof (bool)
                || type == typeof (DateTime) || type == typeof (TimeSpan) || type.IsEnum) {
                return "INTEGER";
            } else if (type == typeof (byte[])) {
                return "BLOB";
            } else {
                throw new Exception (String.Format (
                    "The type {0} cannot be bound to a database column.", type.Name));
            }
        }

Usage Example

 void CheckProperty(Type type, DbColumn column)
 {
     if (!Connection.ColumnExists(TableName, column.Name))
     {
         AddColumnToTable(SqliteUtils.BuildColumnSchema(
                              SqliteUtils.GetType(type),
                              column.Name, column.DefaultValue, column.Constraints));
     }
 }
All Usage Examples Of Hyena.Data.Sqlite.SqliteUtils::GetType