/// <summary> /// Constructs a new primitive store attribute with the given primitive type, column name and auto conversion option. /// </summary> /// <param name="primitive_type">The primitive type to store.</param> /// <param name="p_column_name">The name of the column to store the data in.</param> /// <param name="auto_convert">Whether the field this attribute is associated with should be automatically converted to the given primitive type.</param> /// <param name="store_options">Specifies how the data should be loaded.</param> public CPrimitiveAttribute(EDBPrimitive primitive_type, String p_column_name, Boolean auto_convert, EStoreOptions store_options) { switch (store_options) { case EStoreOptions.none: throw new ArgumentException("ELoadOptions.none is not a valid option."); case EStoreOptions.direct_assignment: case EStoreOptions.user_callback: break; default: throw new ArgumentException(store_options.ToString() + " is not a valid option."); } switch (primitive_type) { case EDBPrimitive.none: throw new ArgumentException("EDBPrimitive.none is not a valid primitive-type to store data with."); case EDBPrimitive.binary: case EDBPrimitive.bit: case EDBPrimitive.boolean: case EDBPrimitive.@char: case EDBPrimitive.@decimal: case EDBPrimitive.@double: case EDBPrimitive.@float: case EDBPrimitive.int16: case EDBPrimitive.int24: case EDBPrimitive.int32: case EDBPrimitive.int64: case EDBPrimitive.int8: case EDBPrimitive.uint16: case EDBPrimitive.uint24: case EDBPrimitive.uint32: case EDBPrimitive.uint64: case EDBPrimitive.uint8: case EDBPrimitive.varbinary: case EDBPrimitive.varchar: case EDBPrimitive.date: case EDBPrimitive.datetime: case EDBPrimitive.time: case EDBPrimitive.timestamp: case EDBPrimitive.year: case EDBPrimitive.text: case EDBPrimitive.infer: break; default: throw new ArgumentException(primitive_type.ToString() + " is not a valid primitive-type to store data with."); } m_primitive_type = primitive_type; m_p_column_name = p_column_name; m_auto_convert = auto_convert; m_store_options = store_options; }
internal static Object MakePrimitiveType(String p_value, EDBPrimitive db_primitive) { switch (db_primitive) { case EDBPrimitive.binary: case EDBPrimitive.varbinary: return(p_value.FromHexToBytes()); case EDBPrimitive.@char: case EDBPrimitive.varchar: case EDBPrimitive.text: return(p_value); case EDBPrimitive.int8: return(SByte.Parse(p_value)); case EDBPrimitive.int16: return(Int16.Parse(p_value)); case EDBPrimitive.int24: case EDBPrimitive.int32: case EDBPrimitive.year: return(Int32.Parse(p_value)); case EDBPrimitive.int64: return(Int64.Parse(p_value)); case EDBPrimitive.uint8: return(Byte.Parse(p_value)); case EDBPrimitive.uint16: return(UInt16.Parse(p_value)); case EDBPrimitive.uint24: case EDBPrimitive.uint32: return(UInt32.Parse(p_value)); case EDBPrimitive.uint64: return(UInt64.Parse(p_value)); case EDBPrimitive.boolean: return(Boolean.Parse(p_value)); case EDBPrimitive.date: case EDBPrimitive.datetime: case EDBPrimitive.time: case EDBPrimitive.timestamp: return(DateTime.Parse(p_value)); default: throw new Exception("Cannot create a primitive type from " + db_primitive.ToString()); } }
public static DbType ToDbType(this EDBPrimitive primitive_type) { switch (primitive_type) { case EDBPrimitive.binary: case EDBPrimitive.varbinary: return(DbType.Binary); case EDBPrimitive.bit: return(DbType.UInt64); case EDBPrimitive.boolean: return(DbType.Boolean); case EDBPrimitive.@char: return(DbType.StringFixedLength); case EDBPrimitive.date: return(DbType.Date); case EDBPrimitive.datetime: return(DbType.DateTime); case EDBPrimitive.@decimal: return(DbType.Decimal); case EDBPrimitive.@double: return(DbType.Double); case EDBPrimitive.@float: return(DbType.Single); case EDBPrimitive.int16: return(DbType.Int16); case EDBPrimitive.int32: return(DbType.Int32); case EDBPrimitive.int64: return(DbType.Int64); case EDBPrimitive.int8: return(DbType.SByte); case EDBPrimitive.time: return(DbType.Time); case EDBPrimitive.timestamp: return(DbType.DateTime); case EDBPrimitive.uint16: return(DbType.UInt16); case EDBPrimitive.uint24: return(DbType.UInt32); case EDBPrimitive.uint32: return(DbType.UInt32); case EDBPrimitive.uint64: return(DbType.UInt64); case EDBPrimitive.uint8: return(DbType.Byte); case EDBPrimitive.varchar: case EDBPrimitive.text: return(DbType.String); case EDBPrimitive.year: return(DbType.Int32); default: throw new InvalidCastException("Cannot convert DBWizard's \"" + primitive_type.ToString() + "\" to a " + typeof(DbType).FullName + "."); } }