DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
DataObject.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 using System.IO;
19 
20 using Deveel.Data;
23 using Deveel.Data.Sql.Objects;
24 using Deveel.Data.Types;
25 
28 
29 namespace Deveel.Data {
34  [Serializable]
35  public sealed class DataObject : IComparable, IComparable<DataObject>, IEquatable<DataObject>, ISerializable {
39  public static readonly DataObject BooleanTrue = new DataObject(PrimitiveTypes.Boolean(), SqlBoolean.True);
40 
44  public static readonly DataObject BooleanFalse = new DataObject(PrimitiveTypes.Boolean(), SqlBoolean.False);
45 
49  public static readonly DataObject BooleanNull = new DataObject(PrimitiveTypes.Boolean(), SqlBoolean.Null);
50 
61  public DataObject(SqlType type, ISqlObject value) {
62  if (type == null)
63  throw new ArgumentNullException("type");
64 
65  Type = type;
66  Value = value;
67  }
68 
69  private DataObject(ObjectData data) {
70  Type = data.GetValue<SqlType>("Type");
71  Value = data.GetValue<ISqlObject>("Value");
72  }
73 
78  public SqlType Type { get; private set; }
79 
84  public ISqlObject Value { get; private set; }
85 
91  public bool IsNull {
92  get {
93  return Type.IsNull ||
94  Value == null ||
95  SqlNull.Value == Value ||
96  Value.IsNull;
97  }
98  }
99 
100  internal int CacheUsage {
101  get { return Type.GetCacheUsage(Value); }
102  }
103 
104  internal bool IsCacheable {
105  get { return Type.IsCacheable(Value); }
106  }
107 
108  internal int Size {
109  get { return Type.ColumnSizeOf(Value); }
110  }
111 
113  data.SetValue("Type", Type);
114  data.SetValue("Value", Value);
115  }
116 
126  public bool IsComparableTo(DataObject obj) {
127  return Type.IsComparable(obj.Type);
128  }
129 
131  public int CompareTo(DataObject other) {
132  // If this is null
133  if (IsNull) {
134  // and value is null return 0 return less
135  if (other.IsNull)
136  return 0;
137  return -1;
138  }
139  // If this is not null and value is null return +1
140  if (ReferenceEquals(null, other) ||
141  other.IsNull)
142  return 1;
143 
144  // otherwise both are non null so compare normally.
145  return CompareToNotNull(other);
146  }
147 
148  private int CompareToNotNull(DataObject other) {
149  var type = Type;
150  // Strings must be handled as a special case.
151  if (type is StringType) {
152  // We must determine the locale to compare against and use that.
153  var stype = (StringType)type;
154  // If there is no locale defined for this type we use the locale in the
155  // given type.
156  if (stype.Locale == null) {
157  type = other.Type;
158  }
159  }
160  return type.Compare(Value, other.Value);
161 
162  }
163 
164  int IComparable.CompareTo(object obj) {
165  return CompareTo((DataObject)obj);
166  }
167 
169  public override int GetHashCode() {
170  unchecked {
171  var code = Type.GetHashCode()*23;
172  if (Value != null)
173  code = code ^ Value.GetHashCode();
174  return code;
175  }
176  }
177 
179  public override bool Equals(object obj) {
180  if (!(obj is DataObject))
181  return false;
182 
183  return Equals((DataObject) obj);
184  }
185 
187  public bool Equals(DataObject other) {
188  if (ReferenceEquals(other, null))
189  return IsNull;
190 
191  var result = IsEqualTo(other);
192  if (result.IsNull)
193  return IsNull;
194 
195  return result.AsBoolean();
196  }
197 
208  public DataObject Is(DataObject other) {
209  if (IsNull && other.IsNull)
210  return BooleanTrue;
211  if (IsComparableTo(other))
212  return Boolean(CompareTo(other) == 0);
213 
214  return BooleanFalse;
215  }
216 
232  public DataObject IsNot(DataObject other) {
233  return Is(other).Negate();
234  }
235 
252  if (IsComparableTo(other) && !IsNull && !other.IsNull)
253  return Boolean(Type.IsEqualTo(Value, other.Value));
254 
255  return BooleanNull;
256  }
257 
274  if (IsComparableTo(other) && !IsNull && !other.IsNull)
275  return Boolean(Type.IsNotEqualTo(Value, other.Value));
276 
277  return BooleanNull;
278  }
279 
281  if (IsComparableTo(other) && !IsNull && !other.IsNull)
282  return Boolean(Type.IsGreatherThan(Value, other.Value));
283 
284  return BooleanNull;
285  }
286 
288  if (IsComparableTo(other) && !IsNull && !other.IsNull)
289  return Boolean(Type.IsSmallerThan(Value, other.Value));
290 
291  return BooleanNull;
292  }
293 
295  if (IsComparableTo(other) && !IsNull && !other.IsNull)
296  return Boolean(Type.IsGreaterOrEqualThan(Value, other.Value));
297 
298  return BooleanNull;
299  }
300 
302  if (IsComparableTo(other) && !IsNull && !other.IsNull)
303  return Boolean(Type.IsSmallerOrEqualThan(Value, other.Value));
304 
305  return BooleanNull;
306  }
307 
324  public DataObject IsLike(DataObject pattern) {
325  if (IsNull || !(Type is StringType))
326  return BooleanNull;
327 
328  if (!(pattern.Type is StringType) ||
329  pattern.IsNull)
330  return BooleanNull;
331 
332  var valueString = (ISqlString) Value;
333  var patternString = (ISqlString) pattern.Value;
334  return Boolean((Type as StringType).IsLike(valueString, patternString));
335  }
336 
337  public DataObject IsNotLike(DataObject pattern) {
338  if (IsNull || !(Type is StringType))
339  return BooleanNull;
340 
341  var valueString = (ISqlString)Value;
342  var patternString = (ISqlString)pattern.Value;
343  return Boolean((Type as StringType).IsNotLike(valueString, patternString));
344  }
345 
359  public DataObject Negate() {
360  if (IsNull)
361  return this;
362 
363  return new DataObject(Type, Type.Negate(Value));
364  }
365 
366  public DataObject Plus() {
367  if (IsNull)
368  return this;
369 
370  return new DataObject(Type, Type.UnaryPlus(Value));
371  }
372 
383  public DataObject Add(DataObject other) {
384  if (IsNull)
385  return this;
386 
387  var widerType = Type.Wider(other.Type);
388  var result = widerType.Add(Value, other.Value);
389  return new DataObject(widerType, result);
390  }
391 
393  if (IsNull)
394  return this;
395 
396  var widerType = Type.Wider(other.Type);
397  var result = widerType.Subtract(Value, other.Value);
398  return new DataObject(widerType, result);
399  }
400 
402  if (IsNull)
403  return this;
404 
405  var widerType = Type.Wider(other.Type);
406  var result = widerType.Multiply(Value, other.Value);
407  return new DataObject(widerType, result);
408  }
409 
410  public DataObject Divide(DataObject other) {
411  if (IsNull)
412  return this;
413 
414  var widerType = Type.Wider(other.Type);
415  var result = widerType.Divide(Value, other.Value);
416  return new DataObject(widerType, result);
417  }
418 
419  public DataObject Modulus(DataObject other) {
420  if (IsNull)
421  return this;
422 
423  var widerType = Type.Wider(other.Type);
424  var result = widerType.Modulus(Value, other.Value);
425  return new DataObject(widerType, result);
426  }
427 
428  public DataObject Or(DataObject other) {
429  if (IsNull)
430  return this;
431 
432  var widerType = Type.Wider(other.Type);
433  var result = widerType.Or(Value, other.Value);
434  return new DataObject(widerType, result);
435  }
436 
437  public DataObject And(DataObject other) {
438  if (IsNull)
439  return this;
440 
441  var widerType = Type.Wider(other.Type);
442  var result = widerType.And(Value, other.Value);
443  return new DataObject(widerType, result);
444  }
445 
446  public DataObject XOr(DataObject other) {
447  if (IsNull)
448  return this;
449 
450  var widerType = Type.Wider(other.Type);
451  var result = widerType.XOr(Value, other.Value);
452  return new DataObject(widerType, result);
453  }
454 
456  if (IsNull)
457  return this;
458 
459  return GroupOperatorHelper.EvaluateAny(type, this, other, context);
460  }
461 
463  if (IsNull)
464  return this;
465 
466  return GroupOperatorHelper.EvaluateAll(type, this, other, context);
467  }
468 
469  public DataObject Reverse() {
470  if (IsNull)
471  return this;
472 
473  return new DataObject(Type, Type.Reverse(Value));
474  }
475 
476  #region Conversion
477 
488  public DataObject CastTo(SqlType destType) {
489  if (!Type.CanCastTo(destType))
490  throw new InvalidCastException();
491 
492  if (Type.Equals(destType))
493  return this;
494 
495  return Type.CastTo(this, destType);
496  }
497 
513  return CastTo(PrimitiveTypes.Boolean());
514  }
515 
517  return CastTo(PrimitiveTypes.TinyInt());
518  }
519 
521  return CastTo(PrimitiveTypes.Numeric(SqlTypeCode.Integer));
522  }
523 
524  public DataObject AsBigInt() {
525  return CastTo(PrimitiveTypes.Numeric(SqlTypeCode.BigInt));
526  }
527 
529  return CastTo(PrimitiveTypes.String(SqlTypeCode.VarChar));
530  }
531 
532  public DataObject AsDate() {
533  return CastTo(PrimitiveTypes.Date());
534  }
535 
537  return CastTo(PrimitiveTypes.TimeStamp());
538  }
539 
540  #endregion
541 
542  #region Object provider
543 
544  public static DataObject Boolean(SqlBoolean value) {
545  return new DataObject(PrimitiveTypes.Boolean(), value);
546  }
547 
548  public static DataObject Boolean(bool value) {
549  return Boolean((SqlBoolean)value);
550  }
551 
552  public static DataObject Number(SqlNumber value) {
553  return Number(PrimitiveTypes.Numeric(), value);
554  }
555 
556  public static DataObject Number(NumericType type, SqlNumber value) {
557  return new DataObject(type, value);
558  }
559 
560  public static DataObject Number(NumericType type, int value) {
561  return new DataObject(type, new SqlNumber(value));
562  }
563 
564  public static DataObject Number(NumericType type, long value) {
565  return new DataObject(type, new SqlNumber(value));
566  }
567 
568  public static DataObject TinyInt(byte value) {
569  return Number(PrimitiveTypes.Numeric(SqlTypeCode.TinyInt), value);
570  }
571 
572  public static DataObject SmallInt(short value) {
573  return Number(PrimitiveTypes.Numeric(SqlTypeCode.SmallInt), value);
574  }
575 
576  public static DataObject Integer(int value) {
577  return Number(PrimitiveTypes.Numeric(SqlTypeCode.Integer), value);
578  }
579 
580  public static DataObject BigInt(long value) {
581  return Number(PrimitiveTypes.Numeric(SqlTypeCode.BigInt), value);
582  }
583 
584  public static DataObject Float(float value) {
585  return Number(PrimitiveTypes.Numeric(SqlTypeCode.Float), new SqlNumber(value));
586  }
587 
588  public static DataObject Double(double value) {
589  return Number(PrimitiveTypes.Numeric(SqlTypeCode.Double), new SqlNumber(value));
590  }
591 
592  public static DataObject String(string s) {
593  return String(new SqlString(s));
594  }
595 
596  public static DataObject String(SqlString s) {
597  return new DataObject(PrimitiveTypes.String(SqlTypeCode.String), s);
598  }
599 
600  public static DataObject Date(DateTimeOffset value) {
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);
604  }
605 
606  public static DataObject Date(SqlDateTime value) {
607  return Date(SqlTypeCode.Date, value);
608  }
609 
610  public static DataObject TimeStamp(SqlDateTime value) {
611  return Date(SqlTypeCode.TimeStamp, value);
612  }
613 
614  public static DataObject Date(SqlTypeCode typeCode, SqlDateTime value) {
615  return new DataObject(PrimitiveTypes.DateTime(typeCode), value);
616  }
617 
618  public static DataObject Time(SqlDateTime value) {
619  return Date(SqlTypeCode.Time, value);
620  }
621 
622  public static DataObject VarChar(string s) {
623  return VarChar(new SqlString(s));
624  }
625 
626  public static DataObject VarChar(SqlString s) {
627  return new DataObject(PrimitiveTypes.String(SqlTypeCode.VarChar), s);
628  }
629 
630  public static DataObject Null(SqlType type) {
631  return new DataObject(type, SqlNull.Value);
632  }
633 
634  public static DataObject Null() {
635  return Null(new NullType(SqlTypeCode.Null));
636  }
637 
638  public static DataObject Binary(SqlBinary binary) {
639  return new DataObject(new BinaryType(SqlTypeCode.Binary), binary);
640  }
641 
642  public static DataObject Binary(byte[] binary) {
643  return Binary(new SqlBinary(binary));
644  }
645 
646  public static DataObject Create(object value) {
647  // Numeric values ...
648  if (value is bool)
649  return Boolean((bool) value);
650  if (value is byte)
651  return TinyInt((byte) value);
652  if (value is short)
653  return SmallInt((short) value);
654  if (value is int)
655  return Integer((int) value);
656  if (value is long)
657  return BigInt((long) value);
658  if (value is float)
659  return Float((float) value);
660  if (value is double)
661  return Double((double) value);
662 
663  if (value is SqlNumber) {
664  var num = (SqlNumber) value;
665  if (num.IsNull)
666  return Null(PrimitiveTypes.Numeric());
667 
668  if (num.CanBeInt32)
669  return Integer(num.ToInt32());
670  if (num.CanBeInt64)
671  return BigInt(num.ToInt64());
672 
673  return Number(num);
674  }
675 
676  // String values ...
677  if (value is string)
678  return String((string) value);
679  if (value is SqlString) {
680  var s = (SqlString) value;
681  if (s.IsNull)
682  return Null(PrimitiveTypes.String());
683 
684  return String(s);
685  }
686 
687  throw new NotSupportedException("Cannot build an object from the given value.");
688  }
689 
690  #endregion
691 
692  #region Operators
693 
704  public static DataObject operator ==(DataObject a, DataObject b) {
705  if (Equals(a, null) && Equals(b, null))
706  return BooleanNull;
707  if (Equals(a, null) || Equals(b, null))
708  return BooleanNull;
709 
710  return a.IsEqualTo(b);
711  }
712 
713 #if !PCL
714  public static DataObject operator ==(DataObject a, DBNull b) {
715  if (Equals(a, null) || a.IsNull)
716  return BooleanTrue;
717 
718  return BooleanFalse;
719  }
720 
721  public static DataObject operator !=(DataObject a, DBNull b) {
722  return !(a == b);
723  }
724 
725 #endif
726 
737  public static DataObject operator !=(DataObject a, DataObject b) {
738  if (Equals(a, null) && Equals(b, null))
739  return BooleanNull;
740  if (Equals(a, null) || Equals(b, null))
741  return BooleanNull;
742 
743  return a.IsNotEqualTo(b);
744  }
745 
756  public static DataObject operator +(DataObject a, DataObject b) {
757  if (Equals(a, null) && Equals(b, null))
758  return Null();
759  if (Equals(a, null))
760  return Null();
761 
762  return a.Add(b);
763  }
764 
775  public static DataObject operator -(DataObject a, DataObject b) {
776  if (Equals(a, null) && Equals(b, null))
777  return Null();
778  if (Equals(a, null))
779  return Null();
780 
781  return a.Subtract(b);
782  }
783 
784  public static DataObject operator /(DataObject a, DataObject b) {
785  if (Equals(a, null) && Equals(b, null))
786  return Null();
787  if (Equals(a, null))
788  return Null();
789 
790  return a.Divide(b);
791  }
792 
793  public static DataObject operator *(DataObject a, DataObject b) {
794  if (Equals(a, null) && Equals(b, null))
795  return Null();
796  if (Equals(a, null))
797  return Null();
798 
799  return a.Multiply(b);
800  }
801 
802  public static DataObject operator %(DataObject a, DataObject b) {
803  if (Equals(a, null) && Equals(b, null))
804  return Null();
805  if (Equals(a, null))
806  return Null();
807 
808  return a.Modulus(b);
809  }
810 
811  public static DataObject operator &(DataObject a, DataObject b) {
812  if (Equals(a, null) && Equals(b, null))
813  return Null();
814  if (Equals(a, null))
815  return Null();
816 
817  return a.And(b);
818  }
819 
820  public static bool operator true(DataObject a) {
821  return a.IsEqualTo(DataObject.BooleanTrue);
822  }
823 
824  public static bool operator false(DataObject a) {
826  }
827 
828  public static DataObject operator |(DataObject a, DataObject b) {
829  if (Equals(a, null) && Equals(b, null))
830  return Null();
831  if (Equals(a, null))
832  return Null();
833 
834  return a.Or(b);
835  }
836 
837  public static DataObject operator ^(DataObject a, DataObject b) {
838  if (Equals(a, null) && Equals(b, null))
839  return Null();
840  if (Equals(a, null))
841  return Null();
842 
843  return a.XOr(b);
844  }
845 
846  public static DataObject operator !(DataObject value) {
847  return value.Negate();
848  }
849 
850  public static DataObject operator -(DataObject value) {
851  return value.Negate();
852  }
853 
854  public static DataObject operator ~(DataObject value) {
855  return value.Reverse();
856  }
857 
858  public static DataObject operator +(DataObject value) {
859  return value.Plus();
860  }
861 
862  #endregion
863 
864  #region Implicit Operators
865 
866  public static implicit operator bool(DataObject value) {
867  if (ReferenceEquals(value, null) || value.IsNull)
868  throw new InvalidCastException("Cannot convert a NULL value to a boolean.");
869 
870  return (SqlBoolean) value.AsBoolean().Value;
871  }
872 
873  public static implicit operator int(DataObject value) {
874  if (ReferenceEquals(value, null) || value.IsNull)
875  throw new InvalidCastException("Cannot convert NULL value to integer.");
876 
877  return ((SqlNumber)value.AsInteger().Value).ToInt32();
878  }
879 
880  public static implicit operator long(DataObject value) {
881  if (ReferenceEquals(value, null) || value.IsNull)
882  throw new InvalidCastException("Cannot convert NULL to long integer");
883 
884  return ((SqlNumber) value.AsBigInt().Value).ToInt64();
885  }
886 
887  public static implicit operator string(DataObject value) {
888  if (ReferenceEquals(value, null) || value.IsNull)
889  return null;
890 
891  return ((SqlString) value.AsVarChar().Value).Value;
892  }
893 
894  public static implicit operator DateTime?(DataObject value) {
895  if (ReferenceEquals(value, null) || value.IsNull)
896  return null;
897 
898  return ((SqlDateTime) value.AsDate().Value).ToDateTime();
899  }
900 
901  public static implicit operator DateTime(DataObject value) {
902  if (ReferenceEquals(value, null) || value.IsNull)
903  throw new InvalidCastException("Cannot convert NULL value to a non-nullable date time.");
904 
905  return ((SqlDateTime)value.AsDate().Value).ToDateTime();
906  }
907 
908 #if !PCL
909  public static implicit operator DBNull(DataObject value) {
910  if (ReferenceEquals(value, null) || value.IsNull)
911  return DBNull.Value;
912 
913  throw new InvalidCastException("Cannot convert non-nullable value to DBNull.");
914  }
915 
916 #endif
917 
918  #endregion
919 
920  public void SerializeValueTo(Stream stream, ISystemContext systemContext) {
921  Type.SerializeObject(stream, Value);
922  }
923 
924  public static void Serialize(DataObject obj, BinaryWriter writer) {
925  if (Equals(obj, null)) {
926  writer.Write((byte)0);
927  return;
928  }
929 
930  writer.Write((byte)1);
931  TypeSerializer.SerializeTo(writer, obj.Type);
932  obj.Type.SerializeObject(writer.BaseStream, obj.Value);
933  }
934 
935  public static DataObject Deserialize(BinaryReader reader, ITypeResolver resolver) {
936  // TODO: this is messy and ugly: must review the whole object and type serialization logic...
937  var status = reader.ReadByte();
938  if (status == 0)
939  return null;
940 
941  var type = TypeSerializer.Deserialize(reader.BaseStream, resolver);
942  var obj = type.DeserializeObject(reader.BaseStream);
943 
944  return new DataObject(type, obj);
945  }
946  }
947 }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
static DataObject Date(DateTimeOffset value)
Definition: DataObject.cs:600
static readonly DataObject BooleanFalse
The representation of a BOOLEAN false as DataObject
Definition: DataObject.cs:44
DataObject(SqlType type, ISqlObject value)
Constructs a new database data object with a specific SqlType and handling the specified ISqlObject v...
Definition: DataObject.cs:61
bool IsNull
Gets a value that indicates if this object is materialized as null.
Definition: DataObject.cs:91
static void SerializeTo(BinaryWriter writer, SqlType type)
DataObject Multiply(DataObject other)
Definition: DataObject.cs:401
static DataObject Integer(int value)
Definition: DataObject.cs:576
void GetData(SerializeData data)
static DataObject Binary(SqlBinary binary)
Definition: DataObject.cs:638
SqlType Type
Gets the SqlType that defines the object properties
Definition: DataObject.cs:78
A long string in the system.
The execution context of a database system, that is defining the configurations and the components us...
DataObject AsTimeStamp()
Definition: DataObject.cs:536
static DataObject Binary(byte[] binary)
Definition: DataObject.cs:642
override bool Equals(object obj)
Definition: DataObject.cs:179
DataObject AsBoolean()
Converts this object to a boolean type.
Definition: DataObject.cs:512
DataObject AsDate()
Definition: DataObject.cs:532
DataObject CastTo(SqlType destType)
Converts this object to the given SqlType.
Definition: DataObject.cs:488
static BooleanType Boolean()
static SqlType Deserialize(BinaryReader reader, ITypeResolver resolver)
Implements a BINARY object that handles a limited number of bytes, not exceding MaxLength.
Definition: SqlBinary.cs:27
static DataObject Double(double value)
Definition: DataObject.cs:588
static DataObject Number(SqlNumber value)
Definition: DataObject.cs:552
A 8-bytes long integer type.
static DataObject Date(SqlTypeCode typeCode, SqlDateTime value)
Definition: DataObject.cs:614
DataObject Divide(DataObject other)
Definition: DataObject.cs:410
static DataObject Null(SqlType type)
Definition: DataObject.cs:630
static DataObject Create(object value)
Definition: DataObject.cs:646
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 (
Definition: DataObject.cs:324
DataObject Modulus(DataObject other)
Definition: DataObject.cs:419
static readonly DataObject BooleanTrue
The representation of a BOOLEAN true as DataObject
Definition: DataObject.cs:39
static DataObject EvaluateAll(SqlExpressionType plainType, DataObject ob1, DataObject ob2, EvaluateContext context)
static void Serialize(DataObject obj, BinaryWriter writer)
Definition: DataObject.cs:924
ISqlObject Value
Gets the underlined value that is handled.
Definition: DataObject.cs:84
static DataObject String(string s)
Definition: DataObject.cs:592
static DataObject Boolean(SqlBoolean value)
Definition: DataObject.cs:544
DataObject AsBigInt()
Definition: DataObject.cs:524
An integer number of 2 bytes.
DataObject IsSmallerThan(DataObject other)
Definition: DataObject.cs:287
int CompareToNotNull(DataObject other)
Definition: DataObject.cs:148
SqlExpressionType
All the possible type of SqlExpression supported
static DataObject Number(NumericType type, SqlNumber value)
Definition: DataObject.cs:556
static DataObject Date(SqlDateTime value)
Definition: DataObject.cs:606
bool IsComparableTo(DataObject obj)
Checks if the given object is comparable to this object,
Definition: DataObject.cs:126
static readonly SqlNull Value
Definition: SqlNull.cs:24
static DataObject Null()
Definition: DataObject.cs:634
Defines the contract for a valid SQL Object
Definition: ISqlObject.cs:23
DataObject AsVarChar()
Definition: DataObject.cs:528
DataObject IsEqualTo(DataObject other)
Compares to the given object to verify if is it equal to the current.
Definition: DataObject.cs:251
static NumericType Numeric()
DataObject AsInteger()
Definition: DataObject.cs:520
DataObject IsNotLike(DataObject pattern)
Definition: DataObject.cs:337
int CompareTo(DataObject other)
Definition: DataObject.cs:131
DataObject IsSmallerOrEqualThan(DataObject other)
Definition: DataObject.cs:301
void SerializeValueTo(Stream stream, ISystemContext systemContext)
Definition: DataObject.cs:920
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35
static DataObject VarChar(SqlString s)
Definition: DataObject.cs:626
DataObject IsGreaterThan(DataObject other)
Definition: DataObject.cs:280
static DataObject Time(SqlDateTime value)
Definition: DataObject.cs:618
static DataObject Number(NumericType type, long value)
Definition: DataObject.cs:564
static DataObject TimeStamp(SqlDateTime value)
Definition: DataObject.cs:610
DataObject Is(DataObject other)
Compares to the given object to verify if is it compatible.
Definition: DataObject.cs:208
DataObject XOr(DataObject other)
Definition: DataObject.cs:446
Defines the properties of a specific SQL Type and handles the values compatible.
Definition: SqlType.cs:33
DataObject IsGreterOrEqualThan(DataObject other)
Definition: DataObject.cs:294
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
virtual ISqlObject DeserializeObject(Stream stream)
Definition: SqlType.cs:404
static DataObject TinyInt(byte value)
Definition: DataObject.cs:568
DataObject(ObjectData data)
Definition: DataObject.cs:69
static DataObject VarChar(string s)
Definition: DataObject.cs:622
static NumericType TinyInt(int size)
static DataObject Boolean(bool value)
Definition: DataObject.cs:548
virtual void SerializeObject(Stream stream, ISqlObject obj)
Definition: SqlType.cs:399
static DataObject BigInt(long value)
Definition: DataObject.cs:580
DataObject IsNotEqualTo(DataObject other)
Compares to the given object to verify if is it not equal to the current.
Definition: DataObject.cs:273
DataObject AsTinyInt()
Definition: DataObject.cs:516
static DataObject SmallInt(short value)
Definition: DataObject.cs:572
DataObject Negate()
Negates the current underlying value of the object.
Definition: DataObject.cs:359
static DataObject Deserialize(BinaryReader reader, ITypeResolver resolver)
Definition: DataObject.cs:935
DataObject And(DataObject other)
Definition: DataObject.cs:437
static DataObject Float(float value)
Definition: DataObject.cs:584
A data type that represents the NULL value of a given SQL data type.
Definition: NullType.cs:29
static DataObject String(SqlString s)
Definition: DataObject.cs:596
DataObject Any(SqlExpressionType type, DataObject other, EvaluateContext context)
Definition: DataObject.cs:455
bool Equals(DataObject other)
Definition: DataObject.cs:187
override int GetHashCode()
Definition: DataObject.cs:169
Encapsulates the elements needed to evaluate an SqlExpression
The most simple implementation of a SQL string with a small size
Definition: SqlString.cs:42
DataObject IsNot(DataObject other)
Compares the given object to verify if it is not compatible with this one.
Definition: DataObject.cs:232
DataObject All(SqlExpressionType type, DataObject other, EvaluateContext context)
Definition: DataObject.cs:462
DataObject Subtract(DataObject other)
Definition: DataObject.cs:392
DataObject Add(DataObject other)
Adds the given value to this object value.
Definition: DataObject.cs:383
virtual int Compare(ISqlObject x, ISqlObject y)
Definition: SqlType.cs:358
Deveel.Data.Sql.Objects.SqlString SqlString
Definition: DataObject.cs:27
DataObject Reverse()
Definition: DataObject.cs:469
DataObject Or(DataObject other)
Definition: DataObject.cs:428
An SQL object handling a single-byte value that represents the concept of boolean true and false...
Definition: SqlBoolean.cs:35
static DataObject EvaluateAny(SqlExpressionType plainType, DataObject ob1, DataObject ob2, EvaluateContext context)
static DataObject Number(NumericType type, int value)
Definition: DataObject.cs:560