63 throw new ArgumentNullException(
"type");
100 internal int CacheUsage {
101 get {
return Type.GetCacheUsage(Value); }
104 internal bool IsCacheable {
105 get {
return Type.IsCacheable(Value); }
109 get {
return Type.ColumnSizeOf(Value); }
127 return Type.IsComparable(obj.
Type);
140 if (ReferenceEquals(null, other) ||
145 return CompareToNotNull(other);
153 var stype = (StringType)type;
156 if (stype.Locale == null) {
164 int IComparable.CompareTo(
object obj) {
171 var code = Type.GetHashCode()*23;
173 code = code ^ Value.GetHashCode();
179 public override bool Equals(
object obj) {
183 return Equals((DataObject) obj);
188 if (ReferenceEquals(other, null))
191 var result = IsEqualTo(other);
195 return result.AsBoolean();
209 if (IsNull && other.
IsNull)
211 if (IsComparableTo(other))
212 return Boolean(CompareTo(other) == 0);
233 return Is(other).Negate();
252 if (IsComparableTo(other) && !IsNull && !other.
IsNull)
274 if (IsComparableTo(other) && !IsNull && !other.
IsNull)
281 if (IsComparableTo(other) && !IsNull && !other.
IsNull)
282 return Boolean(Type.IsGreatherThan(Value, other.
Value));
288 if (IsComparableTo(other) && !IsNull && !other.
IsNull)
295 if (IsComparableTo(other) && !IsNull && !other.
IsNull)
296 return Boolean(Type.IsGreaterOrEqualThan(Value, other.
Value));
302 if (IsComparableTo(other) && !IsNull && !other.
IsNull)
303 return Boolean(Type.IsSmallerOrEqualThan(Value, other.
Value));
328 if (!(pattern.
Type is StringType) ||
334 return Boolean((Type as StringType).IsLike(valueString, patternString));
343 return Boolean((Type as StringType).IsNotLike(valueString, patternString));
363 return new DataObject(Type, Type.Negate(Value));
370 return new DataObject(Type, Type.UnaryPlus(Value));
387 var widerType = Type.Wider(other.
Type);
388 var result = widerType.Add(Value, other.
Value);
396 var widerType = Type.Wider(other.
Type);
397 var result = widerType.Subtract(Value, other.
Value);
405 var widerType = Type.Wider(other.
Type);
406 var result = widerType.Multiply(Value, other.
Value);
414 var widerType = Type.Wider(other.
Type);
415 var result = widerType.Divide(Value, other.
Value);
423 var widerType = Type.Wider(other.
Type);
424 var result = widerType.Modulus(Value, other.
Value);
432 var widerType = Type.Wider(other.
Type);
433 var result = widerType.Or(Value, other.
Value);
441 var widerType = Type.Wider(other.
Type);
442 var result = widerType.And(Value, other.
Value);
450 var widerType = Type.Wider(other.
Type);
451 var result = widerType.XOr(Value, other.
Value);
473 return new DataObject(Type, Type.Reverse(Value));
489 if (!Type.CanCastTo(destType))
490 throw new InvalidCastException();
492 if (Type.Equals(destType))
495 return Type.CastTo(
this, destType);
542 #region Object provider
601 var offset =
new SqlDayToSecond(value.Offset.Days, value.Offset.Hours, value.Offset.Minutes, value.Offset.Seconds, value.Offset.Milliseconds);
602 var sqlDate =
new SqlDateTime(value.Year, value.Month, value.Day, value.Hour, value.Minute, value.Second, value.Millisecond, offset);
603 return Date(sqlDate);
657 return BigInt((
long) value);
659 return Float((
float) value);
661 return Double((
double) value);
664 var num = (SqlNumber) value;
671 return BigInt(num.ToInt64());
678 return String((
string) value);
687 throw new NotSupportedException(
"Cannot build an object from the given value.");
705 if (Equals(a, null) && Equals(b, null))
707 if (Equals(a, null) || Equals(b, null))
715 if (Equals(a, null) || a.
IsNull)
738 if (Equals(a, null) && Equals(b, null))
740 if (Equals(a, null) || Equals(b, null))
757 if (Equals(a, null) && Equals(b, null))
776 if (Equals(a, null) && Equals(b, null))
785 if (Equals(a, null) && Equals(b, null))
794 if (Equals(a, null) && Equals(b, null))
803 if (Equals(a, null) && Equals(b, null))
812 if (Equals(a, null) && Equals(b, null))
829 if (Equals(a, null) && Equals(b, null))
838 if (Equals(a, null) && Equals(b, null))
864 #region Implicit Operators
867 if (ReferenceEquals(value, null) || value.
IsNull)
868 throw new InvalidCastException(
"Cannot convert a NULL value to a boolean.");
874 if (ReferenceEquals(value, null) || value.
IsNull)
875 throw new InvalidCastException(
"Cannot convert NULL value to integer.");
881 if (ReferenceEquals(value, null) || value.
IsNull)
882 throw new InvalidCastException(
"Cannot convert NULL to long integer");
888 if (ReferenceEquals(value, null) || value.
IsNull)
895 if (ReferenceEquals(value, null) || value.IsNull)
898 return ((
SqlDateTime) value.AsDate().Value).ToDateTime();
902 if (ReferenceEquals(value, null) || value.
IsNull)
903 throw new InvalidCastException(
"Cannot convert NULL value to a non-nullable date time.");
910 if (ReferenceEquals(value, null) || value.
IsNull)
913 throw new InvalidCastException(
"Cannot convert non-nullable value to DBNull.");
921 Type.SerializeObject(stream, Value);
925 if (Equals(obj, null)) {
926 writer.Write((byte)0);
930 writer.Write((byte)1);
937 var status = reader.ReadByte();
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
static DataObject Date(DateTimeOffset value)
static readonly DataObject BooleanFalse
The representation of a BOOLEAN false as DataObject
DataObject(SqlType type, ISqlObject value)
Constructs a new database data object with a specific SqlType and handling the specified ISqlObject v...
bool IsNull
Gets a value that indicates if this object is materialized as null.
static void SerializeTo(BinaryWriter writer, SqlType type)
DataObject Multiply(DataObject other)
static DataObject Integer(int value)
void GetData(SerializeData data)
static DataObject Binary(SqlBinary binary)
SqlType Type
Gets the SqlType that defines the object properties
A long string in the system.
The execution context of a database system, that is defining the configurations and the components us...
static DataObject Binary(byte[] binary)
override bool Equals(object obj)
DataObject AsBoolean()
Converts this object to a boolean type.
DataObject CastTo(SqlType destType)
Converts this object to the given SqlType.
static BooleanType Boolean()
static SqlType Deserialize(BinaryReader reader, ITypeResolver resolver)
Implements a BINARY object that handles a limited number of bytes, not exceding MaxLength.
static DataObject Double(double value)
static DataObject Number(SqlNumber value)
A 8-bytes long integer type.
static DataObject Date(SqlTypeCode typeCode, SqlDateTime value)
DataObject Divide(DataObject other)
static DataObject Null(SqlType type)
static DataObject Create(object value)
An integer value that can span from 0 to 255.
void SetValue(string key, Type type, object value)
DataObject IsLike(DataObject pattern)
When the type of this object is a string, this method verifies if the input pattern is compatible (
DataObject Modulus(DataObject other)
static readonly DataObject BooleanTrue
The representation of a BOOLEAN true as DataObject
static DataObject EvaluateAll(SqlExpressionType plainType, DataObject ob1, DataObject ob2, EvaluateContext context)
static void Serialize(DataObject obj, BinaryWriter writer)
ISqlObject Value
Gets the underlined value that is handled.
static DataObject String(string s)
static DataObject Boolean(SqlBoolean value)
An integer number of 2 bytes.
DataObject IsSmallerThan(DataObject other)
int CompareToNotNull(DataObject other)
SqlExpressionType
All the possible type of SqlExpression supported
static DataObject Number(NumericType type, SqlNumber value)
static DataObject Date(SqlDateTime value)
bool IsComparableTo(DataObject obj)
Checks if the given object is comparable to this object,
static readonly SqlNull Value
Defines the contract for a valid SQL Object
static DateType TimeStamp()
DataObject IsEqualTo(DataObject other)
Compares to the given object to verify if is it equal to the current.
static NumericType Numeric()
DataObject IsNotLike(DataObject pattern)
int CompareTo(DataObject other)
DataObject IsSmallerOrEqualThan(DataObject other)
void SerializeValueTo(Stream stream, ISystemContext systemContext)
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
static DataObject VarChar(SqlString s)
static DateType DateTime()
DataObject IsGreaterThan(DataObject other)
static DataObject Time(SqlDateTime value)
static DataObject Number(NumericType type, long value)
static DataObject TimeStamp(SqlDateTime value)
DataObject Is(DataObject other)
Compares to the given object to verify if is it compatible.
DataObject XOr(DataObject other)
Defines the properties of a specific SQL Type and handles the values compatible.
DataObject IsGreterOrEqualThan(DataObject other)
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
virtual ISqlObject DeserializeObject(Stream stream)
static DataObject TinyInt(byte value)
DataObject(ObjectData data)
static DataObject VarChar(string s)
static NumericType TinyInt(int size)
static DataObject Boolean(bool value)
virtual void SerializeObject(Stream stream, ISqlObject obj)
static DataObject BigInt(long value)
DataObject IsNotEqualTo(DataObject other)
Compares to the given object to verify if is it not equal to the current.
static StringType String()
static DataObject SmallInt(short value)
DataObject Negate()
Negates the current underlying value of the object.
object GetValue(string key)
static DataObject Deserialize(BinaryReader reader, ITypeResolver resolver)
DataObject And(DataObject other)
static DataObject Float(float value)
A data type that represents the NULL value of a given SQL data type.
static DataObject String(SqlString s)
DataObject Any(SqlExpressionType type, DataObject other, EvaluateContext context)
bool Equals(DataObject other)
override int GetHashCode()
Encapsulates the elements needed to evaluate an SqlExpression
The most simple implementation of a SQL string with a small size
DataObject IsNot(DataObject other)
Compares the given object to verify if it is not compatible with this one.
DataObject All(SqlExpressionType type, DataObject other, EvaluateContext context)
DataObject Subtract(DataObject other)
DataObject Add(DataObject other)
Adds the given value to this object value.
virtual int Compare(ISqlObject x, ISqlObject y)
Deveel.Data.Sql.Objects.SqlString SqlString
DataObject Or(DataObject other)
An SQL object handling a single-byte value that represents the concept of boolean true and false...
static DataObject EvaluateAny(SqlExpressionType plainType, DataObject ob1, DataObject ob2, EvaluateContext context)
static DataObject Number(NumericType type, int value)