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); }