Ejemplo n.º 1
0
        public void Length()
        {
            var type = new SqlDate(CompressionContext.NoCompression);

            Assert.Throws <ArgumentException>(() => type.GetValue(new byte[2]));
            Assert.Throws <ArgumentException>(() => type.GetValue(new byte[4]));
        }
Ejemplo n.º 2
0
        public void GetParameter()
        {
            SqlType type = new SqlDate(testDate, ParameterDirection.Input);
            TestHelper.AssertSqlParameter(type.GetParameter(), SqlDbType.Date, testDate);

            type = new SqlDate(null, ParameterDirection.Input);
            TestHelper.AssertSqlParameter(type.GetParameter(), SqlDbType.Date, DBNull.Value);
        }
Ejemplo n.º 3
0
        public void GetRawValue()
        {
            SqlType type = new SqlDate(testDate, ParameterDirection.Input);
            Assert.AreEqual(testDate, type.GetRawValue());

            type = new SqlDate(null, ParameterDirection.Input);
            Assert.Null(type.GetRawValue());
        }
Ejemplo n.º 4
0
        public void GetParameter()
        {
            SqlType type = new SqlDate(testDate, ParameterDirection.Input);

            TestHelper.AssertSqlParameter(type.GetParameter(), SqlDbType.Date, testDate);

            type = new SqlDate(null, ParameterDirection.Input);
            TestHelper.AssertSqlParameter(type.GetParameter(), SqlDbType.Date, DBNull.Value);
        }
Ejemplo n.º 5
0
        public void CreateMetaData()
        {
            Assert.Throws<TypeCannotBeUsedAsAClrTypeException>(() => SqlDate.GetTypeHandler().CreateMetaData(null));

            SqlTypeHandler col = new SqlDate(testDate, ParameterDirection.Input);
            var meta = col.CreateMetaData("Test");
            Assert.AreEqual(SqlDbType.Date, meta.SqlDbType);
            Assert.AreEqual("Test", meta.Name);
        }
Ejemplo n.º 6
0
        public void GetRawValue()
        {
            SqlType type = new SqlDate(testDate, ParameterDirection.Input);

            Assert.AreEqual(testDate, type.GetRawValue());

            type = new SqlDate(null, ParameterDirection.Input);
            Assert.Null(type.GetRawValue());
        }
Ejemplo n.º 7
0
        public void CreateMetaData()
        {
            Assert.Throws <TypeCannotBeUsedAsAClrTypeException>(() => SqlDate.GetTypeHandler().CreateMetaData(null));

            SqlTypeHandler col  = new SqlDate(testDate, ParameterDirection.Input);
            var            meta = col.CreateMetaData("Test");

            Assert.AreEqual(SqlDbType.Date, meta.SqlDbType);
            Assert.AreEqual("Test", meta.Name);
        }
Ejemplo n.º 8
0
        public void GetValue()
        {
            var type = new SqlDate(CompressionContext.NoCompression);

            var input = new byte[] { 0xf6, 0x4c, 0x0b };

            Assert.AreEqual(new DateTime(2028, 09, 09), Convert.ToDateTime(type.GetValue(input)));

            input = new byte[] { 0x71, 0x5c, 0x0b };
            Assert.AreEqual(new DateTime(2039, 07, 17), Convert.ToDateTime(type.GetValue(input)));
        }
        private void PopulateClassInfo(DataItemClass c)
        {
            if (IncludesEditingDetails)
            {
                c.Details = Details;
            }

            if (IsPartialSemesterClass)
            {
                if (StartDate != null)
                {
                    c.StartDate = DateTime.SpecifyKind(StartDate.Value.Date, DateTimeKind.Utc);
                    if (!SqlDate.IsValid(c.StartDate))
                    {
                        c.StartDate = SqlDate.MinValue;
                    }
                }
                else
                {
                    c.StartDate = SqlDate.MinValue;
                }

                if (EndDate != null)
                {
                    c.EndDate = DateTime.SpecifyKind(EndDate.Value.Date, DateTimeKind.Utc);
                    if (!SqlDate.IsValid(c.EndDate))
                    {
                        c.EndDate = SqlDate.MinValue;
                    }
                }
                else
                {
                    c.EndDate = SqlDate.MinValue;
                }

                if (StartDate != null || EndDate != null)
                {
                    TelemetryExtension.Current?.TrackEvent("UsedClassStartEndDates");
                }
            }

            else
            {
                c.StartDate = SqlDate.MinValue;
                c.EndDate   = SqlDate.MinValue;
            }
        }
Ejemplo n.º 10
0
        private void withdrawalsBtn_Click(object sender, EventArgs e)
        {
            DatabaseConnector        db      = new DatabaseConnector();
            Dictionary <string, int> allAtms = db.getAllAtms(); // { id, live_money_avilable }

            string[] keys = allAtms.Keys.ToArray();
            int[]    days = { 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 };

            for (int i = 0; i < 1400; i++)
            {
                SqlDate date   = new SqlDate(days[i / 200], 6, 2019);
                Random  random = new Random();
                int     randID = random.Next(0, keys.Length);

                db.makeWithdrawal(keys[randID], date, random.Next(1, 50) * 100);
            }

            MessageBox.Show("All withdrawals saved successfuly");
        }
Ejemplo n.º 11
0
        protected override string GetColumnCreationMethod(SqlColumn column)
        {
            var type = column.Types[Version];

            return(type.SqlTypeInfo switch
            {
                SqlChar _ => $"{nameof(Generic1Columns.AddChar)}(\"{column.Name}\", {type.Length?.ToString("D", CultureInfo.InvariantCulture)}",
                SqlNChar _ => $"{nameof(Generic1Columns.AddNChar)}(\"{column.Name}\", {type.Length?.ToString("D", CultureInfo.InvariantCulture)}, {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                SqlVarChar _ => $"{nameof(Generic1Columns.AddVarChar)}(\"{column.Name}\", {type.Length?.ToString("D", CultureInfo.InvariantCulture)}, {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                SqlNVarChar _ => $"{nameof(Generic1Columns.AddNVarChar)}(\"{column.Name}\", {type.Length?.ToString("D", CultureInfo.InvariantCulture)}, {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                SqlFloatSmall _ => $"{nameof(Generic1Columns.AddFloatSmall)}(\"{column.Name}\", {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                SqlFloatLarge _ => $"{nameof(Generic1Columns.AddFloatLarge)}(\"{column.Name}\", {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                SqlBit _ => $"{nameof(Generic1Columns.AddBit)}(\"{column.Name}\", {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                SqlByte _ => $"{nameof(Generic1Columns.AddByte)}(\"{column.Name}\", {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                SqlInt16 _ => $"{nameof(Generic1Columns.AddInt16)}(\"{column.Name}\", {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                SqlInt32 _ => $"{nameof(Generic1Columns.AddInt32)}(\"{column.Name}\", {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                SqlInt64 _ => $"{nameof(Generic1Columns.AddInt64)}(\"{column.Name}\", {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                SqlNumber _ => $"{nameof(Generic1Columns.AddNumber)}(\"{column.Name}\", {type.Length?.ToString("D", CultureInfo.InvariantCulture)}, {type.Scale?.ToString("D", CultureInfo.InvariantCulture)}, {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                SqlDate _ => $"{nameof(Generic1Columns.AddDate)}(\"{column.Name}\", {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                SqlTime _ => $"{nameof(Generic1Columns.AddTime)}(\"{column.Name}\", {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                SqlDateTime _ => $"{nameof(Generic1Columns.AddDateTime)}(\"{column.Name}\", {type.IsNullable.ToString(CultureInfo.InvariantCulture)}",
                _ => throw new NotImplementedException($"Unmapped type: {type.SqlTypeInfo}"),
            });
Ejemplo n.º 12
0
        /*
        ** Name: allocateRowBuffer
        **
        ** Description:
        **	Allocate the column data array for a row and populate
        **	the array with a SqlData object for each column based
        **	on the column data type.
        **
        ** Input:
        **	rsmd		Row-set Meta-data.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	SqlData[]	Column data array.
        **
        ** History:
        **	14-May-99 (gordy)
        **	    Created.
        **	10-May-01 (gordy)
        **	    The character datatypes (CHAR, VARCHAR, LONGVARCHAR) may now
        **	    be sent as UCS2 character arrays in addition to the existing
        **	    Ingres Character Set strings.  The DBMS datatype is used to
        **	    distinguish the transport format.
        **	31-Oct-02 (gordy)
        **	    Adapted for generic GCF driver.
        **	 4-Aug-03 (gordy)
        **	    Extracted from readData() to separate row and column processing.
        **	22-Sep-03 (gordy)
        **	    Changed to use SQL Data objects to hold column values.
        **	 6-Jan-04 (thoda04)
        **	    Added BigInt support.
        **	16-Jun-06 (gordy)
        **	    ANSI Date/Time data type support.
        **	 7-Dec-09 (gordy, ported by thoda04)
        **	    Support BOOLEAN columns.
        */
        private SqlData[] allocateRowBuffer( AdvanRSMD rsmd )
        {
            SqlData[] row = new SqlData[ rsmd.count ];

            for( int col = 0; col < rsmd.count; col++ )
            {
                switch( rsmd.desc[ col ].sql_type )
                {
                    case ProviderType.DBNull :	row[ col ] = new SqlNull();	break;
                    case ProviderType.TinyInt :	row[ col ] = new SqlTinyInt();	break;
                    case ProviderType.SmallInt:	row[ col ] = new SqlSmallInt();	break;
                    case ProviderType.Integer :	row[ col ] = new SqlInt();	break;
                    case ProviderType.BigInt:  	row[ col ] = new SqlBigInt();	break;
                    case ProviderType.Single :	row[ col ] = new SqlReal();	break;
                    case ProviderType.Double :	row[ col ] = new SqlDouble();	break;
                    case ProviderType.Numeric:
                    case ProviderType.Decimal :	row[ col ] = new SqlDecimal();	break;
                    case ProviderType.Boolean :	row[ col ] = new SqlBool();   	break;

                    case ProviderType.Date :	row[col] = new SqlDate(); break;

                    case ProviderType.Time:
                        row[col] = new SqlTime(rsmd.desc[col].dbms_type);
                        break;

                    case ProviderType.Interval:
                    case ProviderType.IntervalDayToSecond:
                    case ProviderType.IntervalYearToMonth:
                        row[col] = new SqlInterval(rsmd.desc[col].dbms_type);
                        break;

                    case ProviderType.DateTime:
                        switch (rsmd.desc[col].dbms_type)
                        {
                            case DBMS_TYPE_IDATE:
                                row[col] = new IngresDate(conn.osql_dates,
                                                 conn.timeValuesInGMT());
                                break;

                            default:
                                row[col] = new SqlTimestamp(rsmd.desc[col].dbms_type);
                                break;
                        }
                        break;

                    case ProviderType.Binary :
                        row[ col ] = new SqlByte( rsmd.desc[ col ].length );
                        break;

                    case ProviderType.VarBinary :
                        row[ col ] = new SqlVarByte( rsmd.desc[ col ].length );
                        break;

                    case ProviderType.Char :
                        if ( rsmd.desc[ col ].dbms_type != DBMS_TYPE_NCHAR )
                            row[ col ] = new SqlChar( msg.getCharSet(),
                                rsmd.desc[ col ].length );
                        else
                            row[ col ] = new SqlNChar(rsmd.desc[col].length / 2 );
                        break;

                    case ProviderType.VarChar :
                        if ( rsmd.desc[ col ].dbms_type != DBMS_TYPE_NVARCHAR )
                            row[col] = new SqlVarChar(msg.getCharSet(),
                                rsmd.desc[col].length );
                        else
                            row[col] = new SqlNVarChar( rsmd.desc[col].length / 2 );
                        break;

                    case ProviderType.LongVarBinary :
                        row[ col ] = new SqlLongByte( (SqlStream.IStreamListener)this );
                        break;

                    case ProviderType.LongVarChar :
                        if ( rsmd.desc[ col ].dbms_type != DBMS_TYPE_LONG_NCHAR )
                            row[ col ] = new SqlLongChar( msg.getCharSet(),
                                (SqlStream.IStreamListener)this );
                        else
                            row[ col ] = new SqlLongNChar(
                                (SqlStream.IStreamListener)this );
                        break;

                    default :
                        if ( trace.enabled( 1 ) )
                            trace.write( tr_id + ": unexpected SQL type " +
                                rsmd.desc[ col ].sql_type );
                        throw SqlEx.get( ERR_GC4002_PROTOCOL_ERR );
                }
            }

            return( row );
        }
Ejemplo n.º 13
0
 /*
 ** Name: write
 **
 ** Description:
 **	Write a SqlDate data value to the current input message.
 **
 **	A SqlDate data value is composed of a data indicator byte
 **	which, if not NULL, may be followed by a string which is
 **	composed of a two byte integer indicating the byte length
 **	of the string followed by a character byte array of the
 **	indicated length.
 **
 ** Input:
 **	value	SQL data value.
 **
 ** Output:
 **	None.
 **
 ** Returns:
 **	void.
 **
 ** History:
 **	19-Jun-06 (gordy)
 **	    Created.
 */
 public void write(SqlDate value)
 {
     if (writeSqlDataIndicator(value)) write(value.get());
     return;
 }
        public void Save()
        {
            TryStartDataOperationAndThenNavigate(async delegate
            {
                string name = Name;

                if (string.IsNullOrWhiteSpace(name))
                {
                    new PortableMessageDialog(PowerPlannerResources.GetStringNoNameMessageBody(), PowerPlannerResources.GetStringNoNameMessageHeader()).Show();
                    return;
                }

                DataItemSemester semester;

                if (SemesterToEdit != null)
                {
                    semester = new DataItemSemester()
                    {
                        Identifier = SemesterToEdit.Identifier
                    }
                }
                ;

                else if (AddParams != null)
                {
                    semester = new DataItemSemester()
                    {
                        Identifier      = Guid.NewGuid(),
                        UpperIdentifier = AddParams.YearIdentifier
                    }
                }
                ;

                else
                {
                    throw new NullReferenceException("Either editing semester or add semester param must be initialized.");
                }

                semester.Name = name;

                if (SupportsStartEnd)
                {
                    if (StartDate != null)
                    {
                        semester.Start = DateTime.SpecifyKind(StartDate.Value.Date, DateTimeKind.Utc);

                        if (!SqlDate.IsValid(semester.Start))
                        {
                            semester.Start = DateTime.Today;
                        }
                    }

                    else
                    {
                        semester.Start = PowerPlannerSending.DateValues.UNASSIGNED;
                    }

                    if (EndDate != null)
                    {
                        semester.End = DateTime.SpecifyKind(EndDate.Value.Date, DateTimeKind.Utc);

                        if (!SqlDate.IsValid(semester.End))
                        {
                            semester.End = DateTime.Today;
                        }
                    }

                    else
                    {
                        semester.End = PowerPlannerSending.DateValues.UNASSIGNED;
                    }


                    if (!PowerPlannerSending.DateValues.IsUnassigned(semester.Start) &&
                        !PowerPlannerSending.DateValues.IsUnassigned(semester.End) &&
                        semester.Start > semester.End)
                    {
                        new PortableMessageDialog(PowerPlannerResources.GetString("EditSemesterPage_String_StartDateGreaterThanEndExplanation"), PowerPlannerResources.GetString("EditSemesterPage_String_InvalidStartDate")).Show();
                        return;
                    }
                }

                DataChanges changes = new DataChanges();
                changes.Add(semester);

                await PowerPlannerApp.Current.SaveChanges(changes);
            }, delegate
Ejemplo n.º 15
0
 public void GetTypeHandler()
 {
     Assert.IsInstanceOf <SqlTypeHandler>(SqlDate.GetTypeHandler());
 }
Ejemplo n.º 16
0
 public void CreateParamFromValue()
 {
     Assert.Throws <TypeCannotBeUsedAsAClrTypeException>(() => SqlDate.GetTypeHandler().CreateParamFromValue("Test", null));
 }
Ejemplo n.º 17
0
        private void WiseAlgBtn_Click(object sender, EventArgs e)
        {
            DatabaseConnector db = new DatabaseConnector();

            Dictionary <string, int>            atms           = db.getAllAtms();
            Dictionary <string, DictionaryData> allAtmsWithAVG = new Dictionary <string, DictionaryData>(); // { id: '', { avg: [7 cels], liveMoney: int} }
            bool showWithdrawalsErr = false;

            string[] ids = atms.Keys.ToArray();

            for (int i = 0; i < ids.Length; i++)
            {
                // Set the id of the atm and the money its contains
                allAtmsWithAVG.Add(ids[i], new DictionaryData(atms[ids[i]]));
                int[] allDaysAvg = new int[7];

                // Fill the avg of each day
                for (int j = 1; j <= 7; j++)
                {
                    allDaysAvg[j - 1] = db.getAvgWithdrawalsOfDay(ids[i], j);
                }

                allAtmsWithAVG[ids[i]].avg = allDaysAvg;


                // Calculate the date the money will end or will be critical
                int daysUntilEmpty = 0;
                int day            = (int)DateTime.Now.DayOfWeek;

                if (withdrawalsExists(allAtmsWithAVG[ids[i]].avg))
                {
                    while (allAtmsWithAVG[ids[i]].liveMoneyAvilable >= 0)
                    {
                        allAtmsWithAVG[ids[i]].liveMoneyAvilable -= allAtmsWithAVG[ids[i]].avg[day];

                        daysUntilEmpty++;
                        day++;
                        if (day >= 7)
                        {
                            day = 1;
                        }
                    }

                    // Book into Track at the date needed
                    DateTime today     = DateTime.Now;
                    DateTime emptyDay  = today.AddDays(daysUntilEmpty - 2);
                    SqlDate  emptyDate = new SqlDate(emptyDay.Day, emptyDay.Month, emptyDay.Year);

                    // Check if exists Track at this day
                    Track[] allTracksAtEmptyDate = db.getTracksByDate(emptyDate);
                    if (allTracksAtEmptyDate.Length > 0)
                    {
                        for (int j = 0; j < allTracksAtEmptyDate.Length; j++)
                        {
                            if (allTracksAtEmptyDate[j].atms.Length < 6 && !allTracksAtEmptyDate[j].is_done)
                            {
                                // Insert this ATM into this Track
                                db.addAtmToTrack(int.Parse(ids[i]), int.Parse(db.getIdByTrack(allTracksAtEmptyDate[j]))); // ids[i] -> currentAtmID
                            }
                        }
                    }
                    else
                    {
                        // Creates new Track with the specified atm inside
                        int newTrackID = db.addTrack(
                            new Track(
                                null,
                                false,
                                emptyDate,
                                db.getRandID(RandChooser.Car),
                                db.getRandID(RandChooser.Employee),
                                db.getRandID(RandChooser.Admin)
                                )
                            );
                        db.addAtmToTrack(int.Parse(ids[i]), newTrackID);
                    }
                }
                else
                {
                    showWithdrawalsErr = true;
                }
            }

            if (showWithdrawalsErr)
            {
                MessageBox.Show("There is no withdrawals to work with, Please withdrawal and try again");
            }
        }
Ejemplo n.º 18
0
 /*
 ** Name: readSqlData
 **
 ** Description:
 **	Reads a SqlDate data value from the current input message.
 **
 **	A SqlDate data value is composed of a data indicator byte
 **	which, if not NULL, may be followed by a string which is
 **	composed of a two byte integer indicating the byte length
 **	of the string followed by a character byte array of the
 **	indicated length.
 **
 ** Input:
 **	None.
 **
 ** Output:
 **	value	SQL data value.
 **
 ** Returns:
 **	void.
 **
 ** History:
 **	16-Jun-06 (gordy)
 **	    Created.
 */
 public void readSqlData(SqlDate value)
 {
     if (readSqlDataIndicator())	// Read data indicator byte.
         value.set(readString());	// Read data value.
     else
         value.setNull();		// NULL data value.
     return;
 }
        public async void Save()
        {
            try
            {
                string name = Name;

                if (string.IsNullOrWhiteSpace(name))
                {
                    await new PortableMessageDialog(PowerPlannerResources.GetStringNoNameMessageBody(), PowerPlannerResources.GetStringNoNameMessageHeader()).ShowAsync();
                    return;
                }

                DataItemMegaItem holiday;

                if (HolidayToEdit != null)
                {
                    holiday = new DataItemMegaItem()
                    {
                        Identifier = HolidayToEdit.Identifier
                    }
                }
                ;

                else if (AddParams != null)
                {
                    holiday = new DataItemMegaItem()
                    {
                        Identifier      = Guid.NewGuid(),
                        UpperIdentifier = AddParams.SemesterIdentifier,
                        MegaItemType    = PowerPlannerSending.MegaItemType.Holiday
                    }
                }
                ;

                else
                {
                    throw new NullReferenceException("Either editing holiday or add holiday param must be initialized.");
                }

                holiday.Name = name;

                holiday.Date = DateTime.SpecifyKind(StartDate.Date, DateTimeKind.Utc);

                if (!SqlDate.IsValid(holiday.Date))
                {
                    holiday.Date = DateTime.Today;
                }

                holiday.EndTime = DateTime.SpecifyKind(EndDate.Date, DateTimeKind.Utc);
                holiday.EndTime = holiday.EndTime.AddDays(1).AddSeconds(-1);

                if (!SqlDate.IsValid(holiday.EndTime))
                {
                    holiday.EndTime = DateTime.Today;
                }



                if (holiday.Date > holiday.EndTime)
                {
                    await new PortableMessageDialog(PowerPlannerResources.GetString("EditSemesterPage_String_StartDateGreaterThanEndExplanation"), PowerPlannerResources.GetString("EditSemesterPage_String_InvalidStartDate")).ShowAsync();
                    return;
                }

                DataChanges changes = new DataChanges();
                changes.Add(holiday);

                TryStartDataOperationAndThenNavigate(async delegate
                {
                    await PowerPlannerApp.Current.SaveChanges(changes);
                }, delegate
                {
                    this.RemoveViewModel();
                });
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
Ejemplo n.º 20
0
        /// <summary />
        internal object GetValueFromRow(IRow row, int index, out int copied)
        {
            copied = 0;

            object retval = null;

            if (this.ScopeType == typeof(long))
            {
                long?longValue = row.Get <long?>(index);
                if (longValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = longValue.Value;
                    copied = sizeof(long);
                }
            }
            else if (this.ScopeType == typeof(SqlInt64))
            {
                SqlInt64 longValue = row.Get <SqlInt64>(index);
                if (longValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = longValue.Value;
                    copied = sizeof(long);
                }
            }
            else if (this.ScopeType == typeof(int))
            {
                int?intValue = row.Get <int?>(index);
                if (intValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = intValue.Value;
                    copied = sizeof(int);
                }
            }
            else if (this.ScopeType == typeof(SqlInt32))
            {
                SqlInt32 intValue = row.Get <SqlInt32>(index);
                if (intValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = intValue.Value;
                    copied = sizeof(int);
                }
            }
            else if (this.ScopeType == typeof(short))
            {
                short?shortValue = row.Get <short?>(index);
                if (shortValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = shortValue.Value;
                    copied = sizeof(short);
                }
            }
            else if (this.ScopeType == typeof(SqlInt16))
            {
                SqlInt16 shortValue = row.Get <SqlInt16>(index);
                if (shortValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = shortValue.Value;
                    copied = sizeof(short);
                }
            }
            else if (this.ScopeType == typeof(byte))
            {
                byte?byteValue = row.Get <byte?>(index);
                if (byteValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = byteValue.Value;
                    copied = 1;
                }
            }
            else if (this.ScopeType == typeof(SqlByte))
            {
                SqlByte byteValue = row.Get <SqlByte>(index);
                if (byteValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = byteValue.Value;
                    copied = 1;
                }
            }
            else if (this.ScopeType == typeof(string))
            {
                string stringValue = row.Get <string>(index);
                if (stringValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    copied = Encoding.UTF8.GetByteCount(stringValue);

                    ValidateDataSize(row.Schema[index].Name, index, copied);

                    retval = Encoding.UTF8.GetBytes(stringValue);
                }
            }
            else if (this.ScopeType == typeof(byte[]))
            {
                byte[] binaryValue = row.Get <byte[]>(index);
                if (binaryValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    copied = binaryValue.Length;

                    ValidateDataSize(row.Schema[index].Name, index, copied);

                    retval = binaryValue;
                }
            }
            else if (this.ScopeType == typeof(SqlString))
            {
                SqlString stringValue = row.Get <SqlString>(index);
                if (stringValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    copied = Encoding.UTF8.GetByteCount(stringValue.Value);

                    ValidateDataSize(row.Schema[index].Name, index, copied);

                    retval = Encoding.UTF8.GetBytes(stringValue.Value);
                }
            }
            else if (this.ScopeType == typeof(char))
            {
                char?charValue = row.Get <char?>(index);
                if (charValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    var tmpChar = charValue.Value.ToString();
                    retval = Encoding.UTF8.GetBytes(tmpChar);
                    copied = Encoding.UTF8.GetByteCount(tmpChar);
                }
            }
            else if (this.ScopeType == typeof(DateTime))
            {
                DateTime?dateTimeValue = row.Get <DateTime?>(index);
                if (dateTimeValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = dateTimeValue.Value;
                    copied = 8;
                }
            }
            else if (this.ScopeType == typeof(SqlDate))
            {
                SqlDate dateTimeValue = row.Get <SqlDate>(index);
                if (dateTimeValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = dateTimeValue.Value;
                    copied = 8;
                }
            }
            else if (this.ScopeType == typeof(decimal))
            {
                decimal?decimalValue = row.Get <decimal?>(index);
                if (decimalValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = DecimalSerializationHelper.SerializeDecToByteArray(decimalValue.Value);
                    copied = DecimalSerializationHelper.StoredDecimalSize;
                }
            }
            else if (this.ScopeType == typeof(SqlDecimal))
            {
                SqlDecimal decimalValue = row.Get <SqlDecimal>(index);
                if (decimalValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = decimalValue.Value;
                    copied = sizeof(decimal);
                }
            }
            else if (this.ScopeType == typeof(bool))
            {
                bool?boolValue = row.Get <bool?>(index);
                if (boolValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = boolValue.Value;
                    copied = 1;
                }
            }
            else if (this.ScopeType == typeof(SqlBit))
            {
                SqlBit boolValue = row.Get <SqlBit>(index);
                if (boolValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = boolValue.Value;
                    copied = 1;
                }
            }
            else if (this.ScopeType == typeof(float))
            {
                float?floatValue = row.Get <float?>(index);
                if (floatValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = floatValue.Value;
                    copied = sizeof(float);
                }
            }
            else if (this.ScopeType == typeof(double))
            {
                double?doubleValue = row.Get <double?>(index);
                if (doubleValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = doubleValue.Value;
                    copied = sizeof(double);
                }
            }
            else if (this.ScopeType == typeof(sbyte))
            {
                sbyte?sbyteValue = row.Get <sbyte?>(index);
                if (sbyteValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = sbyteValue.Value;
                    copied = sizeof(sbyte);
                }
            }
            else if (this.ScopeType == typeof(uint))
            {
                uint?uintValue = row.Get <uint?>(index);
                if (uintValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = uintValue.Value;
                    copied = sizeof(uint);
                }
            }
            else if (this.ScopeType == typeof(ushort))
            {
                ushort?ushortValue = row.Get <ushort?>(index);
                if (ushortValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = ushortValue.Value;
                    copied = sizeof(ushort);
                }
            }
            else if (this.ScopeType == typeof(SqlGuid))
            {
                SqlGuid guidValue = row.Get <SqlGuid>(index);
                if (guidValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = guidValue.Value;
                    copied = 16;
                }
            }
            else if (this.ScopeType == typeof(Guid))
            {
                Guid?guidValue = row.Get <Guid?>(index);
                if (guidValue == null)
                {
                    retval = DBNull.Value;
                }
                else
                {
                    retval = guidValue.Value;
                    copied = 16;
                }
            }

            return(retval);
        }