22 namespace Deveel.Data.Types {
25 : base(GetTypeString(typeCode), typeCode) {
26 AssertIsInterval(typeCode);
29 public override bool IsIndexable {
35 return "DAY TO SECOND";
37 return "YEAR TO MONTH";
43 if (!IsIntervalType(sqlType))
44 throw new ArgumentException(
String.Format(
"SQL Type {0} is not a valid INTERVAL.", sqlType.ToString().ToUpperInvariant()));
53 return typeof (TimeSpan);
55 return base.GetRuntimeType();
64 return base.GetObjectType();
73 return TypeCode.Equals(type.
TypeCode);
77 var writer =
new BinaryWriter(stream);
80 var interval = (SqlDayToSecond) obj;
81 var bytes = interval.ToByArray();
83 writer.Write((byte)1);
84 writer.Write(bytes.Length);
87 var interval = (SqlYearToMonth) obj;
88 var months = interval.TotalMonths;
90 writer.Write((byte)2);
94 throw new FormatException();
98 var reader =
new BinaryReader(stream);
100 var type = reader.ReadByte();
103 var length = reader.ReadInt32();
104 var bytes = reader.ReadBytes(length);
107 throw new NotImplementedException();
110 var months = reader.ReadInt32();
114 return base.DeserializeObject(stream);
override void SerializeObject(Stream stream, ISqlObject obj)
A long string in the system.
override Type GetRuntimeType()
override Type GetObjectType()
SqlTypeCode TypeCode
Gets the kind of SQL type this data-type handles.
IntervalType(SqlTypeCode typeCode)
Defines the contract for a valid SQL Object
override bool IsComparable(SqlType type)
Verifies if a given SqlType is comparable to this data-type.
override ISqlObject DeserializeObject(Stream stream)
static string GetTypeString(SqlTypeCode sqlType)
override bool IsCacheable(ISqlObject value)
Defines the properties of a specific SQL Type and handles the values compatible.
static void AssertIsInterval(SqlTypeCode sqlType)
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
A month span representation of time.
static bool IsIntervalType(SqlTypeCode sqlType)