Пример #1
0
 public static Guid? GetGuid(DbDataReader reader, int index)
 {
     if (reader.IsDBNull(index))
         return null;
     else
         return reader.GetGuid(index);
 }
Пример #2
0
 static int GetGuid(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         System.Data.Common.DbDataReader obj = (System.Data.Common.DbDataReader)ToLua.CheckObject(L, 1, typeof(System.Data.Common.DbDataReader));
         int         arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         System.Guid o    = obj.GetGuid(arg0);
         ToLua.PushValue(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #3
0
        // Copy multiple fields from reader to SmiTypedGetterSetter
        //  Supports V200 code path, without damaging backward compat for V100 code.
        //  Main differences are supporting DbDataReader, and for binary, character, decimal and Udt types.
        //  Assumes caller enforces that reader and setter metadata are compatible
        internal static void FillCompatibleSettersFromReader(SmiEventSink_Default sink, SmiTypedGetterSetter setters, IList<SmiExtendedMetaData> metaData, DbDataReader reader) {
            for (int i = 0; i < metaData.Count; i++) {
                if (reader.IsDBNull(i)) {
                    ValueUtilsSmi.SetDBNull_Unchecked(sink, setters, i);
                }
                else {
                    switch (metaData[i].SqlDbType) {
                        case SqlDbType.BigInt:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Int64));
                            SetInt64_Unchecked(sink, setters, i, reader.GetInt64(i));
                            break;
                        case SqlDbType.Binary:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.ByteArray));
                            SetBytes_FromReader(sink, setters, i, metaData[i], reader, 0);
                            break;
                        case SqlDbType.Bit:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Boolean));
                            SetBoolean_Unchecked(sink, setters, i, reader.GetBoolean(i));
                            break;
                        case SqlDbType.Char:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.CharArray));
                            SetCharsOrString_FromReader(sink, setters, i, metaData[i], reader, 0);
                            break;
                        case SqlDbType.DateTime:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.DateTime));
                            SetDateTime_Checked(sink, setters, i, metaData[i], reader.GetDateTime(i));
                            break;
                        case SqlDbType.Decimal: { // block to scope sqlReader local to avoid conflicts
                                Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlDecimal));
                                // Support full fidelity for SqlDataReader
                                SqlDataReader sqlReader = reader as SqlDataReader;
                                if (null != sqlReader) {
                                    SetSqlDecimal_Unchecked(sink, setters, i, sqlReader.GetSqlDecimal(i));
                                }
                                else {
                                    SetSqlDecimal_Unchecked(sink, setters, i, new SqlDecimal(reader.GetDecimal(i)));
                                }
                            }
                            break;
                        case SqlDbType.Float:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Double));
                            SetDouble_Unchecked(sink, setters, i, reader.GetDouble(i));
                            break;
                        case SqlDbType.Image:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.ByteArray));
                            SetBytes_FromReader(sink, setters, i, metaData[i], reader, 0);
                            break;
                        case SqlDbType.Int:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Int32));
                            SetInt32_Unchecked(sink, setters, i, reader.GetInt32(i));
                            break;
                        case SqlDbType.Money:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlMoney));
                            SetSqlMoney_Checked(sink, setters, i, metaData[i], new SqlMoney(reader.GetDecimal(i)));
                            break;
                        case SqlDbType.NChar:
                        case SqlDbType.NText:
                        case SqlDbType.NVarChar:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.CharArray));
                            SetCharsOrString_FromReader(sink, setters, i, metaData[i], reader, 0);
                            break;
                        case SqlDbType.Real:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Single));
                            SetSingle_Unchecked(sink, setters, i, reader.GetFloat(i));
                            break;
                        case SqlDbType.UniqueIdentifier:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Guid));
                            SetGuid_Unchecked(sink, setters, i, reader.GetGuid(i));
                            break;
                        case SqlDbType.SmallDateTime:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.DateTime));
                            SetDateTime_Checked(sink, setters, i,metaData[i], reader.GetDateTime(i));
                            break;
                        case SqlDbType.SmallInt:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Int16));
                            SetInt16_Unchecked(sink, setters, i, reader.GetInt16(i));
                            break;
                        case SqlDbType.SmallMoney:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlMoney));
                            SetSqlMoney_Checked(sink, setters, i, metaData[i], new SqlMoney(reader.GetDecimal(i)));
                            break;
                        case SqlDbType.Text:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.CharArray));
                            SetCharsOrString_FromReader(sink, setters, i, metaData[i], reader, 0);
                            break;
                        case SqlDbType.Timestamp:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.ByteArray));
                            SetBytes_FromReader(sink, setters, i, metaData[i], reader, 0);
                            break;
                        case SqlDbType.TinyInt:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Byte));
                            SetByte_Unchecked(sink, setters, i, reader.GetByte(i));
                            break;
                        case SqlDbType.VarBinary:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.ByteArray));
                            SetBytes_FromReader(sink, setters, i, metaData[i], reader, 0);
                            break;
                        case SqlDbType.VarChar:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.String));
                            SetCharsOrString_FromReader(sink, setters, i, metaData[i], reader, 0);
                            break;
                        case SqlDbType.Xml: {
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlXml));
                                SqlDataReader sqlReader = reader as SqlDataReader;
                                if (null != sqlReader) {
                                    SetSqlXml_Unchecked(sink, setters, i, sqlReader.GetSqlXml(i));
                                }
                                else {
                                    SetBytes_FromReader(sink, setters, i, metaData[i], reader, 0);
                                }
                            }
                            break;
                        case SqlDbType.Variant: {  // block to scope sqlReader local and avoid conflicts
                                // Support better options for SqlDataReader
                                SqlDataReader sqlReader = reader as SqlDataReader;
                                SqlBuffer.StorageType storageType = SqlBuffer.StorageType.Empty;
                                object o;
                                if (null != sqlReader) {
                                    o = sqlReader.GetSqlValue(i);
                                    storageType = sqlReader.GetVariantInternalStorageType(i);
                                }
                                else {
                                    o = reader.GetValue(i);
                                }
                                ExtendedClrTypeCode typeCode = MetaDataUtilsSmi.DetermineExtendedTypeCodeForUseWithSqlDbType(metaData[i].SqlDbType, metaData[i].IsMultiValued, o, null,
                                    // 

                                    SmiContextFactory.KatmaiVersion
                                    );
                                if ((storageType == SqlBuffer.StorageType.DateTime2) || (storageType == SqlBuffer.StorageType.Date))
                                    SetCompatibleValueV200(sink, setters, i, metaData[i], o, typeCode, 0, 0, null, storageType);
                                else
                                    SetCompatibleValueV200(sink, setters, i, metaData[i], o, typeCode, 0, 0, null);
                            }
                            break;

                        case SqlDbType.Udt:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.ByteArray));
                            // Skip serialization for Udt types.
                            SetBytes_FromReader(sink, setters, i, metaData[i], reader, 0);
                            break;

                        // SqlDbType.Structured should have been caught before this point for TVPs.  SUDTs will still need to implement.

                        case SqlDbType.Date:
                        case SqlDbType.DateTime2:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.DateTime));
                            SetDateTime_Checked(sink, setters, i, metaData[i], reader.GetDateTime(i));
                            break;
                        case SqlDbType.Time: { // block to scope sqlReader local and avoid conflicts
                                Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.TimeSpan));
                                SqlDataReader sqlReader = reader as SqlDataReader;
                                TimeSpan ts;
                                if (null != sqlReader) {
                                    ts = sqlReader.GetTimeSpan(i);
                                } else {
                                    ts = (TimeSpan)reader.GetValue(i);
                                }
                                SetTimeSpan_Checked(sink, setters, i, metaData[i], ts);
                            }
                            break;
                        case SqlDbType.DateTimeOffset: { // block to scope sqlReader local and avoid conflicts
                                Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.DateTimeOffset));
                                SqlDataReader sqlReader = reader as SqlDataReader;
                                DateTimeOffset dto;
                                if (null != sqlReader) {
                                    dto = sqlReader.GetDateTimeOffset(i);
                                } else {
                                    dto = (DateTimeOffset)reader.GetValue(i);
                                }
                                SetDateTimeOffset_Unchecked(sink, setters, i, dto);
                            }
                            break;

                        default:
                            // In order for us to get here we would have to have an 
                            // invalid instance of SqlDbType, or one would have to add 
                            // new member to SqlDbType without adding a case in this 
                            // switch, hence the assert - it must be 

                            Debug.Assert(false, "unsupported DbType:" + metaData[i].SqlDbType.ToString());
                            throw ADP.NotSupported();

                    }
                }
            }
        }
Пример #4
0
		MembershipUser GetUserFromReader (DbDataReader reader)
		{
			return new MembershipUser (this.Name, /* XXX is this right?  */
						   reader.GetString (0), /* name */
						   reader.GetGuid (1), /* providerUserKey */
						   reader.IsDBNull (2) ? null : reader.GetString (2), /* email */
						   reader.IsDBNull (3) ? null : reader.GetString (3), /* passwordQuestion */
						   reader.IsDBNull (4) ? null : reader.GetString (4), /* comment */
						   reader.GetBoolean (5), /* isApproved */
						   reader.GetBoolean (6), /* isLockedOut */
						   reader.GetDateTime (7).ToLocalTime (), /* creationDate */
						   reader.GetDateTime (8).ToLocalTime (), /* lastLoginDate */
						   reader.GetDateTime (9).ToLocalTime (), /* lastActivityDate */
						   reader.GetDateTime (10).ToLocalTime (), /* lastPasswordChangedDate */
						   reader.GetDateTime (11).ToLocalTime () /* lastLockoutDate */);
		}
Пример #5
0
 protected override object ReadInternal(DbDataReader reader, int ordinal, SqlRandomTableColumn columnInfo, Type asType)
 {
     ValidateReadType(typeof(Guid), asType);
     if (reader.IsDBNull(ordinal))
         return DBNull.Value;
     return reader.GetGuid(ordinal);
 }
Пример #6
0
		MembershipUser GetUserFromReader (DbDataReader reader, string username, object userId)
		{
			int i = 0;
			if (username == null)
				i = 1;

			if (userId != null)
				username = reader.GetString (8);

			return new MembershipUser (this.Name, /* XXX is this right?  */
				(username == null ? reader.GetString (0) : username), /* name */
				(userId == null ? reader.GetGuid (8 + i) : userId), /* providerUserKey */
				reader.IsDBNull (0 + i) ? null : reader.GetString (0 + i), /* email */
				reader.IsDBNull (1 + i) ? null : reader.GetString (1 + i), /* passwordQuestion */
				reader.IsDBNull (2 + i) ? null : reader.GetString (2 + i), /* comment */
				reader.GetBoolean (3 + i), /* isApproved */
				reader.GetBoolean (9 + i), /* isLockedOut */
				reader.GetDateTime (4 + i).ToLocalTime (), /* creationDate */
				reader.GetDateTime (5 + i).ToLocalTime (), /* lastLoginDate */
				reader.GetDateTime (6 + i).ToLocalTime (), /* lastActivityDate */
				reader.GetDateTime (7 + i).ToLocalTime (), /* lastPasswordChangedDate */
				reader.GetDateTime (10 + i).ToLocalTime () /* lastLockoutDate */);
		}
 internal static void FillCompatibleSettersFromReader(SmiEventSink_Default sink, SmiTypedGetterSetter setters, IList<SmiExtendedMetaData> metaData, DbDataReader reader)
 {
     for (int i = 0; i < metaData.Count; i++)
     {
         object sqlValue;
         DateTimeOffset dateTimeOffset;
         TimeSpan timeSpan;
         ExtendedClrTypeCode code;
         if (reader.IsDBNull(i))
         {
             SetDBNull_Unchecked(sink, setters, i);
             continue;
         }
         switch (metaData[i].SqlDbType)
         {
             case SqlDbType.BigInt:
             {
                 SetInt64_Unchecked(sink, setters, i, reader.GetInt64(i));
                 continue;
             }
             case SqlDbType.Binary:
             {
                 SetBytes_FromReader(sink, setters, i, metaData[i], reader, 0);
                 continue;
             }
             case SqlDbType.Bit:
             {
                 SetBoolean_Unchecked(sink, setters, i, reader.GetBoolean(i));
                 continue;
             }
             case SqlDbType.Char:
             {
                 SetCharsOrString_FromReader(sink, setters, i, metaData[i], reader, 0);
                 continue;
             }
             case SqlDbType.DateTime:
             {
                 SetDateTime_Checked(sink, setters, i, metaData[i], reader.GetDateTime(i));
                 continue;
             }
             case SqlDbType.Decimal:
             {
                 SqlDataReader reader6 = reader as SqlDataReader;
                 if (reader6 == null)
                 {
                     break;
                 }
                 SetSqlDecimal_Unchecked(sink, setters, i, reader6.GetSqlDecimal(i));
                 continue;
             }
             case SqlDbType.Float:
             {
                 SetDouble_Unchecked(sink, setters, i, reader.GetDouble(i));
                 continue;
             }
             case SqlDbType.Image:
             {
                 SetBytes_FromReader(sink, setters, i, metaData[i], reader, 0);
                 continue;
             }
             case SqlDbType.Int:
             {
                 SetInt32_Unchecked(sink, setters, i, reader.GetInt32(i));
                 continue;
             }
             case SqlDbType.Money:
             {
                 SetSqlMoney_Checked(sink, setters, i, metaData[i], new SqlMoney(reader.GetDecimal(i)));
                 continue;
             }
             case SqlDbType.NChar:
             case SqlDbType.NText:
             case SqlDbType.NVarChar:
             {
                 SetCharsOrString_FromReader(sink, setters, i, metaData[i], reader, 0);
                 continue;
             }
             case SqlDbType.Real:
             {
                 SetSingle_Unchecked(sink, setters, i, reader.GetFloat(i));
                 continue;
             }
             case SqlDbType.UniqueIdentifier:
             {
                 SetGuid_Unchecked(sink, setters, i, reader.GetGuid(i));
                 continue;
             }
             case SqlDbType.SmallDateTime:
             {
                 SetDateTime_Checked(sink, setters, i, metaData[i], reader.GetDateTime(i));
                 continue;
             }
             case SqlDbType.SmallInt:
             {
                 SetInt16_Unchecked(sink, setters, i, reader.GetInt16(i));
                 continue;
             }
             case SqlDbType.SmallMoney:
             {
                 SetSqlMoney_Checked(sink, setters, i, metaData[i], new SqlMoney(reader.GetDecimal(i)));
                 continue;
             }
             case SqlDbType.Text:
             {
                 SetCharsOrString_FromReader(sink, setters, i, metaData[i], reader, 0);
                 continue;
             }
             case SqlDbType.Timestamp:
             {
                 SetBytes_FromReader(sink, setters, i, metaData[i], reader, 0);
                 continue;
             }
             case SqlDbType.TinyInt:
             {
                 SetByte_Unchecked(sink, setters, i, reader.GetByte(i));
                 continue;
             }
             case SqlDbType.VarBinary:
             {
                 SetBytes_FromReader(sink, setters, i, metaData[i], reader, 0);
                 continue;
             }
             case SqlDbType.VarChar:
             {
                 SetCharsOrString_FromReader(sink, setters, i, metaData[i], reader, 0);
                 continue;
             }
             case SqlDbType.Variant:
             {
                 SqlDataReader reader4 = reader as SqlDataReader;
                 if (reader4 == null)
                 {
                     goto Label_0311;
                 }
                 sqlValue = reader4.GetSqlValue(i);
                 goto Label_0319;
             }
             case SqlDbType.Xml:
             {
                 SqlDataReader reader5 = reader as SqlDataReader;
                 if (reader5 == null)
                 {
                     goto Label_02E4;
                 }
                 SetSqlXml_Unchecked(sink, setters, i, reader5.GetSqlXml(i));
                 continue;
             }
             case SqlDbType.Udt:
             {
                 SetBytes_FromReader(sink, setters, i, metaData[i], reader, 0);
                 continue;
             }
             case SqlDbType.Date:
             case SqlDbType.DateTime2:
             {
                 SetDateTime_Checked(sink, setters, i, metaData[i], reader.GetDateTime(i));
                 continue;
             }
             case SqlDbType.Time:
             {
                 SqlDataReader reader3 = reader as SqlDataReader;
                 if (reader3 == null)
                 {
                     goto Label_03A0;
                 }
                 timeSpan = reader3.GetTimeSpan(i);
                 goto Label_03AE;
             }
             case SqlDbType.DateTimeOffset:
             {
                 SqlDataReader reader2 = reader as SqlDataReader;
                 if (reader2 == null)
                 {
                     goto Label_03D5;
                 }
                 dateTimeOffset = reader2.GetDateTimeOffset(i);
                 goto Label_03E2;
             }
             default:
                 throw ADP.NotSupported();
         }
         SetSqlDecimal_Unchecked(sink, setters, i, new SqlDecimal(reader.GetDecimal(i)));
         continue;
     Label_02E4:
         SetBytes_FromReader(sink, setters, i, metaData[i], reader, 0);
         continue;
     Label_0311:
         sqlValue = reader.GetValue(i);
     Label_0319:
         code = MetaDataUtilsSmi.DetermineExtendedTypeCodeForUseWithSqlDbType(metaData[i].SqlDbType, metaData[i].IsMultiValued, sqlValue, null, 210L);
         SetCompatibleValueV200(sink, setters, i, metaData[i], sqlValue, code, 0, 0, null);
         continue;
     Label_03A0:
         timeSpan = (TimeSpan) reader.GetValue(i);
     Label_03AE:
         SetTimeSpan_Checked(sink, setters, i, metaData[i], timeSpan);
         continue;
     Label_03D5:
         dateTimeOffset = (DateTimeOffset) reader.GetValue(i);
     Label_03E2:
         SetDateTimeOffset_Unchecked(sink, setters, i, dateTimeOffset);
     }
 }
Пример #8
0
        protected virtual IPersistedRawEvent ReadEvent(DbDataReader reader, Stream stream)
        {
            // select order
            // Field: GlobalSequence, EventID, StreamHash, StreamName, EventType, UtcTimestamp, Metadata, Payload, PayloadFormat
            // Index: 0               1        2           3           4          5             6         7        8

            if (stream != null)
                stream = new Stream(stream, reader.GetString(3));
            else
                stream = new Stream((byte[])reader[2], reader.GetString(3));

            return new PersistedRawEvent
            {
                GlobalSequence = reader.GetInt64(0),
                EventID = reader.GetGuid(1),
                Stream = stream,
                EventType = reader.GetString(4),
                UtcTimestamp = reader.GetDateTime(5),
                Metadata = reader.IsDBNull(6) ? null : (byte[])reader[6],
                Payload = (byte[])reader[7],
                PayloadFormat = reader.GetInt32(8)
            };
        }
Пример #9
0
 /// <summary>
 /// Vendor-independent database reader.
 /// </summary>
 public static Guid ReadGuid(DbDataReader dataReader, int column)
 {
     if (DatabaseLanguageIsMsSql.Value)
         return dataReader.GetGuid(column);
     else if (DatabaseLanguageIsOracle.Value)
         return new Guid(((OracleDataReader)dataReader).GetOracleBinary(column).Value);
     else
         throw new FrameworkException(UnsupportedLanguageError);
 }
Пример #10
0
        public IEnumerable <Bunk> QueryBunkListView(DataTransferObject.Foundation.BunkQueryCondition condition, Core.Pagination pagination)
        {
            var result = new List <Bunk>();

            using (var dbOperator = new DbOperator(Provider, ConnectionString))
            {
                if (!string.IsNullOrWhiteSpace(condition.Airline))
                {
                    dbOperator.AddParameter("@iAirline", condition.Airline.Trim());
                }
                if (!string.IsNullOrWhiteSpace(condition.Departure))
                {
                    dbOperator.AddParameter("@iDeparture", condition.Departure.Trim());
                }
                if (!string.IsNullOrWhiteSpace(condition.Arrival))
                {
                    dbOperator.AddParameter("@iArrival", condition.Arrival.Trim());
                }
                if (!string.IsNullOrWhiteSpace(condition.BunkCode))
                {
                    dbOperator.AddParameter("@iBunkCode", condition.BunkCode.Trim());
                }
                if (condition.BunkType.HasValue)
                {
                    dbOperator.AddParameter("@iBunkType", (int)condition.BunkType);
                }
                if (condition.VoyageType.HasValue)
                {
                    dbOperator.AddParameter("@iVoyageType", (byte)condition.VoyageType);
                }
                if (condition.FlightBeginDate.HasValue)
                {
                    dbOperator.AddParameter("@iFlightBeginDate", condition.FlightBeginDate.Value.Date);
                }
                if (condition.FlightEndDate.HasValue)
                {
                    dbOperator.AddParameter("@iFlightEndDate", condition.FlightEndDate.Value.Date);
                }
                if (condition.Status.HasValue)
                {
                    dbOperator.AddParameter("@iStatus", condition.Status);
                }
                if (pagination != null)
                {
                    dbOperator.AddParameter("@iPageSize", pagination.PageSize);
                    dbOperator.AddParameter("@iPageIndex", pagination.PageIndex);
                }
                System.Data.Common.DbParameter totalCount = dbOperator.AddParameter("@oTotalCount");
                totalCount.DbType    = System.Data.DbType.Int32;
                totalCount.Direction = System.Data.ParameterDirection.Output;
                using (System.Data.Common.DbDataReader reader = dbOperator.ExecuteReader("dbo.P_QueryBunks", System.Data.CommandType.StoredProcedure))
                {
                    Guid?previousId = null;
                    Bunk bunk       = null;
                    while (reader.Read())
                    {
                        var currentId = reader.GetGuid(1);
                        if (bunk == null || previousId.Value != currentId)
                        {
                            bunk = null;
                        }
                        var bunkType = (BunkType)reader.GetInt32(0);
                        switch (bunkType)
                        {
                        case BunkType.Economic:
                            bunk = loadEconomicBunk(bunk, reader);
                            break;

                        case BunkType.FirstOrBusiness:
                            bunk = loadFirstBusinessBunk(bunk, reader);
                            break;

                        case BunkType.Promotion:
                            bunk = loadPromotionBunk(bunk, reader);
                            break;

                        case BunkType.Production:
                            bunk = loadProductionBunk(bunk, reader);
                            break;

                        case BunkType.Transfer:
                            bunk = loadTransferBunk(bunk, reader);
                            break;

                        case BunkType.Free:
                            bunk = loadFreeBunk(bunk, reader);
                            break;

                        case BunkType.Team:
                            bunk = loadTeamBunk(bunk, reader);
                            break;
                        }
                        bunk.VoyageType        = (VoyageTypeValue)reader.GetByte(19);
                        bunk.TravelType        = (TravelTypeValue)reader.GetByte(20);
                        bunk.PassengerType     = (PassengerTypeValue)reader.GetByte(21);
                        bunk.RefundRegulation  = reader.IsDBNull(8) ? string.Empty : reader.GetString(8);
                        bunk.ChangeRegulation  = reader.IsDBNull(16) ? string.Empty : reader.GetString(16);
                        bunk.EndorseRegulation = reader.IsDBNull(17) ? string.Empty : reader.GetString(17);
                        bunk.Remarks           = reader.IsDBNull(18) ? string.Empty : reader.GetString(18);
                        if (!previousId.HasValue || previousId.Value != currentId)
                        {
                            result.Add(bunk);
                            previousId = currentId;
                        }
                    }
                }
                if (pagination.GetRowCount)
                {
                    pagination.RowCount = (int)totalCount.Value;
                }
            }
            return(result);
        }