private object GetColumnInType(object value, SqlType sourceType, SqlType targetType) { if (value == null) { return(DBNull.Value); } if (targetType.TypeCode == 0x6b) { return(new MonthSpan((int)((IntervalMonthData)value).Units)); } if (targetType.TypeCode == 110) { IntervalSecondData data = (IntervalSecondData)value; return(new TimeSpan((data.Units * 0x989680L) + (data.Nanos / 100))); } if (sourceType.TypeCode != targetType.TypeCode) { try { value = targetType.ConvertToTypeAdo(this._command.Connection.InnerConnection.SessionProxy, value, sourceType); } catch (CoreException) { string str = value + "instance of " + value.GetType().Name; string[] textArray1 = new string[] { "from SQL type ", sourceType.GetNameString(), " to ", targetType.GetCSharpClassName(), ", value: ", str }; string add = string.Concat(textArray1); throw UtlException.GetException(Error.GetError(0x15b9, add)); } } return(value); }
private object GetColumnInType(int columnIndex, SqlType targetType) { this.CheckClosed(); this.CheckValidRow(); SqlType otherType = this._rResult.MetaData.ColumnTypes[columnIndex]; object a = this._nCurrent.GetCurrent()[columnIndex]; if (a == null) { return(null); } if (targetType.TypeCode == 0x6b) { return(new MonthSpan((int)((IntervalMonthData)a).Units)); } if (targetType.TypeCode == 110) { IntervalSecondData data = (IntervalSecondData)a; return(new TimeSpan((data.Units * 0x989680L) + (data.Nanos / 100))); } if (otherType.TypeCode != targetType.TypeCode) { try { a = targetType.ConvertToTypeAdo(this._command.Connection.InnerConnection.SessionProxy, a, otherType); } catch (Exception) { try { return(otherType.ConvertToTypeAdo(this._command.Connection.InnerConnection.SessionProxy, a, targetType)); } catch (Exception) { } object[] objArray1 = new object[] { "from SQL type ", otherType.GetNameString(), " to ", targetType.GetCSharpClassName(), ", value: ", a }; string add = string.Concat(objArray1); UtlException.ThrowError(Error.GetError(0x15b9, add)); } return(a); } return(a); }
protected abstract void WriteDaySecondInterval(IntervalSecondData o, SqlType type);
protected override void WriteDaySecondInterval(IntervalSecondData o, SqlType type) { this.WriteLong(o.Units); this.WriteInt(o.Nanos); }
private void SetParameter(int i, UtlParameter param) { object o = param.Value; if ((o == null) || (o == DBNull.Value)) { this._parameterValues[i] = null; return; } ISessionInterface sessionProxy = this._command.Connection.InnerConnection.SessionProxy; SqlType type = this._parameterTypes[i]; int typeCode = type.TypeCode; if (typeCode <= 30) { if (typeCode > 0x15) { switch (typeCode) { case 0x19: case 30: goto Label_028B; } this._parameterValues[i] = o; return; } switch (typeCode) { case 0x15: { DataTable dataTable = o as DataTable; if (dataTable != null) { dataTable.TableName = this._parameterNames[i]; if (!((TableType)this._parameterTypes[i]).IsCompatible(dataTable)) { goto Label_0379; } goto Label_03AF; } DbDataReader reader = o as DbDataReader; if (reader == null) { goto Label_03AF; } dataTable = new DataTable(this._parameterNames[i]); UtlMetaData.PopulateDataTable(dataTable, reader); if (((TableType)this._parameterTypes[i]).IsCompatible(dataTable)) { o = dataTable; goto Label_03AF; } goto Label_0379; } } } else { if (typeCode <= 0x3d) { if (typeCode == 40) { this._parameterValues[i] = o; return; } if ((typeCode - 60) > 1) { goto Label_028B; } byte[] data = o as byte[]; if (data != null) { o = new BinaryData(data, !this._command.Connection.IsNetConnection); } else { try { if (o is string) { o = type.ConvertToDefaultType(sessionProxy, o); goto Label_03AF; } } catch (CoreException exception1) { UtlException.ThrowError(exception1); } UtlException.ThrowError(Error.GetError(0x15bd)); } goto Label_03AF; } switch (typeCode) { case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f: try { if (((param.UtlType == UtlType.Null) && (o is string)) || (((param.UtlType == UtlType.VarChar) || (param.UtlType == UtlType.Char)) || (param.UtlType == UtlType.VarCharIngnoreCase))) { o = type.ConvertToType(sessionProxy, o, SqlType.SqlVarchar); } else { o = type.ConvertCSharpToSQL(sessionProxy, o); } } catch (CoreException exception2) { UtlException.ThrowError(exception2); } goto Label_03AF; case 0x65: case 0x66: case 0x6b: { MonthSpan span = (MonthSpan)o; o = new IntervalMonthData((long)span.TotalMonths); goto Label_03AF; } case 0x67: case 0x68: case 0x69: case 0x6a: case 0x6c: case 0x6d: case 110: case 0x6f: case 0x70: case 0x71: { TimeSpan span2 = (TimeSpan)o; long totalSeconds = (long)span2.TotalSeconds; int nanos = (int)((span2.TotalSeconds - totalSeconds) * 1000000000.0); o = new IntervalSecondData(totalSeconds, nanos); goto Label_03AF; } case 0x457: try { if (o.GetType().IsSerializable) { o = new OtherData(o); goto Label_03AF; } } catch (CoreException exception3) { UtlException.ThrowError(exception3); } UtlException.ThrowError(Error.GetError(0x15bd)); goto Label_03AF; } } Label_028B :; try { if (((param.UtlType == UtlType.Null) && (o is string)) || (((param.UtlType == UtlType.VarChar) || (param.UtlType == UtlType.Char)) || (param.UtlType == UtlType.VarCharIngnoreCase))) { o = type.ConvertToType(sessionProxy, o, SqlType.SqlVarchar); } else if (param.UtlType == UtlType.Null) { o = type.ConvertToDefaultType(sessionProxy, o); } else { SqlType type2 = this.UtlType2SqlType(param.UtlType); o = type.ConvertToType(sessionProxy, o, type2); } } catch (CoreException exception4) { UtlException.ThrowError(exception4); } goto Label_03AF; Label_0379 :; try { if (param.UtlType == UtlType.Null) { o = type.ConvertToDefaultType(sessionProxy, o); } else { SqlType type3 = this.UtlType2SqlType(param.UtlType); o = type.ConvertToType(sessionProxy, o, type3); } } catch (CoreException exception5) { UtlException.ThrowError(exception5); } Label_03AF: this._parameterValues[i] = o; }
public void Add(Session session, object item) { if (item == null) { this._hasNull = true; } else if (!this._isDistinct || this._distinctValues.Add(item)) { this._count++; switch (this._setType) { case 0x47: return; case 0x48: case 0x4b: switch (this._dataType) { case -6: case 4: case 5: int num3; try { num3 = (int)item; } catch (Exception) { num3 = Convert.ToInt32(item); } this._currentLong += num3; return; case 2: case 3: decimal num4; try { num4 = (decimal)item; } catch (Exception) { num4 = Convert.ToDecimal(item); } this._currentBigDecimal += num4; return; case 6: case 7: case 8: double num5; try { num5 = (double)item; } catch (Exception) { num5 = Convert.ToDouble(item); } this._currentDouble += num5; return; case 10: { IntervalSecondData data = item as IntervalSecondData; if (data != null) { this._currentLong += data.Units; this._currentLong += data.Nanos; if (Math.Abs(this._currentLong) >= DTIType.NanoScaleFactors[0]) { this._currentLong += this._currentLong / ((long)DTIType.NanoScaleFactors[0]); this._currentLong = this._currentLong % ((long)DTIType.NanoScaleFactors[0]); return; } } else { IntervalMonthData data2 = item as IntervalMonthData; if (data2 != null) { this._currentLong += data2.Units; } } return; } case 0x19: long num6; try { num6 = (long)item; } catch (Exception) { num6 = Convert.ToInt64(item); } this._currentLong += num6; return; case 0x68: this._currentValue = item; return; } break; case 0x49: if (this._currentValue != null) { if (this._type.Compare(session, this._currentValue, item, this._type, false) > 0) { this._currentValue = item; } return; } this._currentValue = item; return; case 0x4a: if (this._currentValue != null) { if (this._type.Compare(session, this._currentValue, item, this._type, false) < 0) { this._currentValue = item; } return; } this._currentValue = item; return; case 0x4c: if (!(item is bool)) { throw Error.GetError(0x15bd); } this._every = this._every && ((bool)item); return; case 0x4d: if (!(item is bool)) { throw Error.GetError(0x15bd); } this._some = this._some || ((bool)item); return; case 0x4e: case 0x4f: case 80: case 0x51: this.AddDataPoint(item); return; default: throw Error.RuntimeError(0xc9, "SetFunction"); } throw Error.GetError(0x15bd); } }
protected override void WriteDaySecondInterval(IntervalSecondData o, SqlType type) { base.Write(0x27); base.WriteBytes(type.ConvertToString(o)); base.Write(0x27); }