fx\src\data\System\Data\Common\DataStorage.cs (105)
120internal readonly StorageType StorageTypeCode;
134protected DataStorage(DataColumn column, Type type, object defaultValue, StorageType storageType)
138protected DataStorage(DataColumn column, Type type, object defaultValue, object nullValue, StorageType storageType)
142protected DataStorage(DataColumn column, Type type, object defaultValue, object nullValue, bool isICloneable, StorageType storageType) {
152IsStringType = ((StorageType.String == StorageTypeCode) || (StorageType.SqlString == StorageTypeCode));
261public static DataStorage CreateStorage(DataColumn column, Type dataType, StorageType typeCode) {
263if ((StorageType.Empty == typeCode) && (null != dataType)) {
273case StorageType.Empty: throw ExceptionBuilder.InvalidStorageType(TypeCode.Empty);
274case StorageType.DBNull: throw ExceptionBuilder.InvalidStorageType(TypeCode.DBNull);
275case StorageType.Object: return new ObjectStorage(column, dataType);
276case StorageType.Boolean: return new BooleanStorage(column);
277case StorageType.Char: return new CharStorage(column);
278case StorageType.SByte: return new SByteStorage(column);
279case StorageType.Byte: return new ByteStorage(column);
280case StorageType.Int16: return new Int16Storage(column);
281case StorageType.UInt16: return new UInt16Storage(column);
282case StorageType.Int32: return new Int32Storage(column);
283case StorageType.UInt32: return new UInt32Storage(column);
284case StorageType.Int64: return new Int64Storage(column);
285case StorageType.UInt64: return new UInt64Storage(column);
286case StorageType.Single: return new SingleStorage(column);
287case StorageType.Double: return new DoubleStorage(column);
288case StorageType.Decimal: return new DecimalStorage(column);
289case StorageType.DateTime: return new DateTimeStorage(column);
290case StorageType.TimeSpan: return new TimeSpanStorage(column);
291case StorageType.String: return new StringStorage(column);
292case StorageType.Guid: return new ObjectStorage(column, dataType);
294case StorageType.ByteArray: return new ObjectStorage(column, dataType);
295case StorageType.CharArray: return new ObjectStorage(column, dataType);
296case StorageType.Type: return new ObjectStorage(column, dataType);
297case StorageType.DateTimeOffset: return new DateTimeOffsetStorage(column);
298case StorageType.BigInteger: return new BigIntegerStorage(column);
299case StorageType.Uri: return new ObjectStorage(column, dataType);
301case StorageType.SqlBinary: return new SqlBinaryStorage(column);
302case StorageType.SqlBoolean: return new SqlBooleanStorage(column);
303case StorageType.SqlByte: return new SqlByteStorage(column);
304case StorageType.SqlBytes: return new SqlBytesStorage(column);
305case StorageType.SqlChars: return new SqlCharsStorage(column);
306case StorageType.SqlDateTime: return new SqlDateTimeStorage(column); //???/ what to do
307case StorageType.SqlDecimal: return new SqlDecimalStorage(column);
308case StorageType.SqlDouble: return new SqlDoubleStorage(column);
309case StorageType.SqlGuid: return new SqlGuidStorage(column);
310case StorageType.SqlInt16: return new SqlInt16Storage(column);
311case StorageType.SqlInt32: return new SqlInt32Storage(column);
312case StorageType.SqlInt64: return new SqlInt64Storage(column);
313case StorageType.SqlMoney: return new SqlMoneyStorage(column);
314case StorageType.SqlSingle: return new SqlSingleStorage(column);
315case StorageType.SqlString: return new SqlStringStorage(column);
320goto case StorageType.Object;
324internal static StorageType GetStorageType(Type dataType) {
327return (StorageType)i;
332return (StorageType)tcode;
334return StorageType.Empty;
337internal static Type GetTypeStorage(StorageType storageType) {
345internal static bool IsTypeCustomType(StorageType typeCode) {
346return ((StorageType.Object == typeCode) || (StorageType.Empty == typeCode) || (StorageType.CharArray == typeCode));
349internal static bool IsSqlType(StorageType storageType) {
350return (StorageType.SqlBinary <= storageType);
354for (int i = (int)StorageType.SqlBinary; i < StorageClassType.Length; ++i) {
362private static bool DetermineIfValueType(StorageType typeCode, Type dataType) {
365case StorageType.Boolean:
366case StorageType.Char:
367case StorageType.SByte:
368case StorageType.Byte:
369case StorageType.Int16:
370case StorageType.UInt16:
371case StorageType.Int32:
372case StorageType.UInt32:
373case StorageType.Int64:
374case StorageType.UInt64:
375case StorageType.Single:
376case StorageType.Double:
377case StorageType.Decimal:
378case StorageType.DateTime:
379case StorageType.DateTimeOffset:
380case StorageType.BigInteger:
381case StorageType.TimeSpan:
382case StorageType.Guid:
383case StorageType.SqlBinary:
384case StorageType.SqlBoolean:
385case StorageType.SqlByte:
386case StorageType.SqlDateTime:
387case StorageType.SqlDecimal:
388case StorageType.SqlDouble:
389case StorageType.SqlGuid:
390case StorageType.SqlInt16:
391case StorageType.SqlInt32:
392case StorageType.SqlInt64:
393case StorageType.SqlMoney:
394case StorageType.SqlSingle:
395case StorageType.SqlString:
399case StorageType.String:
400case StorageType.ByteArray:
401case StorageType.CharArray:
402case StorageType.Type:
403case StorageType.Uri:
404case StorageType.SqlBytes:
405case StorageType.SqlChars:
418StorageType typeCode,
434else if (StorageType.Empty != typeCode) {
466internal static bool ImplementsINullableValue(StorageType typeCode, Type dataType) {
468return ((StorageType.Empty == typeCode) && dataType.IsGenericType && (dataType.GetGenericTypeDefinition() == typeof(System.Nullable<>)));
fx\src\data\System\Data\Filter\BinaryNode.cs (284)
131internal int BinaryCompare(object vLeft, object vRight, StorageType resultType, int op) {
135internal int BinaryCompare(object vLeft, object vRight, StorageType resultType, int op, CompareInfo comparer) {
140case StorageType.SByte:
141case StorageType.Int16:
142case StorageType.Int32:
143case StorageType.Byte:
144case StorageType.UInt16:
146case StorageType.Int64:
147case StorageType.UInt32:
148case StorageType.UInt64:
149case StorageType.Decimal:
151case StorageType.Char:
153case StorageType.Double:
155case StorageType.Single:
157case StorageType.DateTime:
159case StorageType.DateTimeOffset:
162case StorageType.String:
164case StorageType.Guid:
166case StorageType.Boolean:
176case StorageType.SByte:
177case StorageType.Int16:
178case StorageType.Int32:
179case StorageType.Byte:
180case StorageType.UInt16:
181case StorageType.SqlByte:
182case StorageType.SqlInt16:
183case StorageType.SqlInt32:
185case StorageType.Int64:
186case StorageType.UInt32:
187case StorageType.SqlInt64:
189case StorageType.UInt64:
190case StorageType.SqlDecimal:
192case StorageType.SqlDouble:
194case StorageType.SqlSingle:
196case StorageType.SqlString:
198case StorageType.SqlGuid:
200case StorageType.SqlBoolean:
209case StorageType.SqlBinary:
211case StorageType.SqlDateTime:
213case StorageType.SqlMoney:
240StorageType resultType;
256StorageType leftStorage = DataStorage.GetStorageType(typeofLeft);
257StorageType rightStorage = DataStorage.GetStorageType(typeofRight);
280if (StorageType.Empty == resultType) {
287resultType = StorageType.Empty; // shouldnt we make it boolean?
297case StorageType.Byte:{
300case StorageType.SByte:{
303case StorageType.Int16:{
306case StorageType.UInt16:{
309case StorageType.Int32: {
312case StorageType.UInt32: {
315case StorageType.UInt64: {
318case StorageType.Int64:{
321case StorageType.Decimal:{
324case StorageType.Single:{
327case StorageType.Double:{
330case StorageType.String:
331case StorageType.Char:{
334case StorageType.DateTime:{
347case StorageType.TimeSpan:{
350case StorageType.SqlInt16:{
353case StorageType.SqlInt32:{
356case StorageType.SqlInt64:{
359case StorageType.SqlDouble:{
362case StorageType.SqlSingle:{
365case StorageType.SqlDecimal:{
368case StorageType.SqlMoney:{
371case StorageType.SqlByte:{
374case StorageType.SqlString:{
377case StorageType.SqlDateTime:{
398case StorageType.Byte: {
401case StorageType.SqlByte: {
404case StorageType.SByte:{
407case StorageType.Int16:{
410case StorageType.SqlInt16:{
413case StorageType.UInt16:{
416case StorageType.Int32:{
419case StorageType.SqlInt32:{
422case StorageType.UInt32:{
425case StorageType.Int64:{
428case StorageType.SqlInt64:{
431case StorageType.UInt64:{
434case StorageType.Decimal:{
437case StorageType.SqlDecimal:{
440case StorageType.Single:{
443case StorageType.SqlSingle:{
446case StorageType.Double:{
449case StorageType.SqlDouble:{
452case StorageType.SqlMoney:{
455case StorageType.DateTime:{
458case StorageType.TimeSpan:{
465case StorageType.SqlDateTime:{
486case StorageType.Byte:{
489case StorageType.SqlByte:{
492case StorageType.SByte:{
495case StorageType.Int16:{
498case StorageType.SqlInt16:{
501case StorageType.UInt16:{
504case StorageType.Int32:{
507case StorageType.SqlInt32:{
510case StorageType.UInt32:{
513case StorageType.Int64:{
517case StorageType.SqlInt64:{
520case StorageType.UInt64:{
523case StorageType.Decimal:{
526case StorageType.SqlDecimal:{
529case StorageType.Single:{
532case StorageType.SqlSingle:{
535case StorageType.SqlMoney:{
538case StorageType.Double:{
541case StorageType.SqlDouble:{
552case StorageType.Byte:{
555case StorageType.SqlByte:{
558case StorageType.SByte:{
561case StorageType.Int16:{
564case StorageType.SqlInt16:{
567case StorageType.UInt16:{
570case StorageType.Int32:{
573case StorageType.SqlInt32:{
576case StorageType.UInt32:{
579case StorageType.UInt64:{
582case StorageType.Int64:{
585case StorageType.SqlInt64:{
588case StorageType.Decimal:{
591case StorageType.SqlDecimal:{
594case StorageType.Single:{
597case StorageType.SqlSingle:{
600case StorageType.SqlMoney:{
603case StorageType.Double:{
607case StorageType.SqlDouble:{
784if (resultType == StorageType.UInt64) {
790if (resultType == StorageType.SqlInt32){
793else if (resultType == StorageType.SqlInt16){
796else if (resultType == StorageType.SqlByte){
909private DataTypePrecedence GetPrecedence(StorageType storageType) {
911case StorageType.Boolean: return DataTypePrecedence.Boolean;
912case StorageType.Char: return DataTypePrecedence.Char;
913case StorageType.SByte: return DataTypePrecedence.SByte;
914case StorageType.Byte: return DataTypePrecedence.Byte;
915case StorageType.Int16: return DataTypePrecedence.Int16;
916case StorageType.UInt16: return DataTypePrecedence.UInt16;
917case StorageType.Int32: return DataTypePrecedence.Int32;
918case StorageType.UInt32: return DataTypePrecedence.UInt32;
919case StorageType.Int64: return DataTypePrecedence.Int64;
920case StorageType.UInt64: return DataTypePrecedence.UInt64;
921case StorageType.Single: return DataTypePrecedence.Single;
922case StorageType.Double: return DataTypePrecedence.Double;
923case StorageType.Decimal: return DataTypePrecedence.Decimal;
924case StorageType.DateTime: return DataTypePrecedence.DateTime;
925case StorageType.DateTimeOffset: return DataTypePrecedence.DateTimeOffset;
926case StorageType.TimeSpan: return DataTypePrecedence.TimeSpan;
927case StorageType.String: return DataTypePrecedence.String;
928case StorageType.SqlBinary: return DataTypePrecedence.SqlBinary;
929case StorageType.SqlBoolean: return DataTypePrecedence.SqlBoolean;
930case StorageType.SqlByte: return DataTypePrecedence.SqlByte;
931case StorageType.SqlBytes: return DataTypePrecedence.SqlBytes;
932case StorageType.SqlChars: return DataTypePrecedence.SqlChars;
933case StorageType.SqlDateTime: return DataTypePrecedence.SqlDateTime;
934case StorageType.SqlDecimal: return DataTypePrecedence.SqlDecimal;
935case StorageType.SqlDouble: return DataTypePrecedence.SqlDouble;
936case StorageType.SqlGuid: return DataTypePrecedence.SqlGuid;
937case StorageType.SqlInt16: return DataTypePrecedence.SqlInt16;
938case StorageType.SqlInt32: return DataTypePrecedence.SqlInt32;
939case StorageType.SqlInt64: return DataTypePrecedence.SqlInt64;
940case StorageType.SqlMoney: return DataTypePrecedence.SqlMoney;
941case StorageType.SqlSingle: return DataTypePrecedence.SqlSingle;
942case StorageType.SqlString: return DataTypePrecedence.SqlString;
944case StorageType.Empty:
945case StorageType.Object:
946case StorageType.DBNull:
951private static StorageType GetPrecedenceType(DataTypePrecedence code) {
953case DataTypePrecedence.Error: return StorageType.Empty;
954case DataTypePrecedence.SByte: return StorageType.SByte;
955case DataTypePrecedence.Byte: return StorageType.Byte;
956case DataTypePrecedence.Int16: return StorageType.Int16;
957case DataTypePrecedence.UInt16: return StorageType.UInt16;
958case DataTypePrecedence.Int32: return StorageType.Int32;
959case DataTypePrecedence.UInt32: return StorageType.UInt32;
960case DataTypePrecedence.Int64: return StorageType.Int64;
961case DataTypePrecedence.UInt64: return StorageType.UInt64;
962case DataTypePrecedence.Decimal: return StorageType.Decimal;
963case DataTypePrecedence.Single: return StorageType.Single;
964case DataTypePrecedence.Double: return StorageType.Double;
966case DataTypePrecedence.Boolean: return StorageType.Boolean;
967case DataTypePrecedence.String: return StorageType.String;
968case DataTypePrecedence.Char: return StorageType.Char;
970case DataTypePrecedence.DateTimeOffset: return StorageType.DateTimeOffset;
971case DataTypePrecedence.DateTime: return StorageType.DateTime;
972case DataTypePrecedence.TimeSpan: return StorageType.TimeSpan;
974case DataTypePrecedence.SqlDateTime: return StorageType.SqlDateTime;
975case DataTypePrecedence.SqlDouble: return StorageType.SqlDouble;
976case DataTypePrecedence.SqlSingle: return StorageType.SqlSingle;
977case DataTypePrecedence.SqlDecimal: return StorageType.SqlDecimal;
978case DataTypePrecedence.SqlInt64: return StorageType.SqlInt64;
979case DataTypePrecedence.SqlInt32: return StorageType.SqlInt32;
980case DataTypePrecedence.SqlInt16: return StorageType.SqlInt16;
981case DataTypePrecedence.SqlByte: return StorageType.SqlByte;
982case DataTypePrecedence.SqlBoolean: return StorageType.SqlBoolean;
983case DataTypePrecedence.SqlString: return StorageType.SqlString;
984case DataTypePrecedence.SqlGuid: return StorageType.SqlGuid;
985case DataTypePrecedence.SqlBinary: return StorageType.SqlBinary;
986case DataTypePrecedence.SqlMoney: return StorageType.SqlMoney;
993private bool IsMixed(StorageType left, StorageType right) {
998private bool IsMixedSql(StorageType left, StorageType right) {
1003internal StorageType ResultType(StorageType left, StorageType right, bool lc, bool rc, int op) {
1004if ((left == StorageType.Guid) && (right == StorageType.Guid) && Operators.IsRelational(op))
1006if ((left == StorageType.String) && (right == StorageType.Guid) && Operators.IsRelational(op))
1008if ((left == StorageType.Guid) && (right == StorageType.String) && Operators.IsRelational(op))
1013return StorageType.Empty;
1018return StorageType.Empty;
1022if (left == StorageType.Boolean && right == StorageType.Boolean)
1023return StorageType.Boolean;
1025return StorageType.Empty;
1027if ((left == StorageType.DateTimeOffset) ||(right == StorageType.DateTimeOffset))
1032if (Operators.IsRelational(op) && left == StorageType.DateTimeOffset && right == StorageType.DateTimeOffset)
1033return StorageType.DateTimeOffset;
1034return StorageType.Empty;
1037if ((op == Operators.Plus) && ((left == StorageType.String) || (right == StorageType.String)))
1038return StorageType.String;
1042StorageType result = GetPrecedenceType(higherPrec);
1045if (result != StorageType.String && result != StorageType.Char) {
1047return StorageType.Empty;
1049return StorageType.Empty;
1056return StorageType.Double;
1082internal StorageType ResultSqlType(StorageType left, StorageType right, bool lc, bool rc, int op) {
1085return StorageType.Empty;
1090return StorageType.Empty;
1094if ((left != StorageType.Boolean && left != StorageType.SqlBoolean) || (right != StorageType.Boolean && right != StorageType.SqlBoolean))
1095return StorageType.Empty;
1096if (left == StorageType.Boolean && right == StorageType.Boolean)
1097return StorageType.Boolean;
1098return StorageType.SqlBoolean;
1102if((left == StorageType.SqlString) ||(right == StorageType.SqlString))
1103return StorageType.SqlString;
1104if ((left == StorageType.String) || (right == StorageType.String))
1105return StorageType.String;
1108if ((left == StorageType.SqlBinary && right != StorageType.SqlBinary) ||(left != StorageType.SqlBinary && right == StorageType.SqlBinary))
1109return StorageType.Empty;
1111if((left == StorageType.SqlGuid && right != StorageType.SqlGuid) ||(left != StorageType.SqlGuid && right == StorageType.SqlGuid))
1112return StorageType.Empty;
1115return StorageType.Empty;
1119return StorageType.Empty;
1124if (left == StorageType.TimeSpan)
1126if (right == StorageType.TimeSpan)
1128return StorageType.Empty; // for plus or minus operations for time types, one of them MUST be time span
1132return StorageType.Empty; // we just have relational operations amoung time types
1140StorageType result = GetPrecedenceType(higherPrec);
1145if (result != StorageType.String && result != StorageType.Char && result != StorageType.SqlString) {
1147return StorageType.Empty;
1149return StorageType.Empty;
1155return StorageType.SqlDouble;
1158if (result == StorageType.SqlMoney){
1159if ((left != StorageType.SqlMoney) && (right != StorageType.SqlMoney))
1160result = StorageType.SqlDecimal;
1237string rightStr = (string) SqlConvert.ChangeType2(vRight, StorageType.String, typeof(string), FormatProvider);
fx\src\data\System\Data\Filter\FunctionNode.cs (17)
255StorageType storageType;
273case StorageType.Boolean:
275case StorageType.Int32:
277case StorageType.Double:
279case StorageType.String:
422StorageType mytype = DataStorage.GetStorageType(type);
425if (mytype == StorageType.DateTimeOffset) {
426if (storageType == StorageType.String) {
431if (StorageType.Object != mytype) {
432if ((mytype == StorageType.Guid) && (storageType == StorageType.String))
437if (StorageType.Single == storageType) {
438return SqlConvert.ChangeType2((Single) SqlConvert.ChangeType2(argumentValues[0], StorageType.Single, typeof(Single), FormatProvider), mytype, type, FormatProvider);
440else if (StorageType.Double == storageType) {
441return SqlConvert.ChangeType2((double) SqlConvert.ChangeType2(argumentValues[0], StorageType.Double, typeof(Double), FormatProvider), mytype, type, FormatProvider);
443else if (StorageType.Decimal == storageType) {
444return SqlConvert.ChangeType2((decimal) SqlConvert.ChangeType2(argumentValues[0], StorageType.Decimal, typeof(Decimal), FormatProvider), mytype, type, FormatProvider);