Esempio n. 1
0
        /// <summary>
        /// Reads the values from an <see cref="IDataRecord"/> and assigns the read values to this
        /// object's properties. The database column's name is used to as the key, so the value
        /// will not be found if any aliases are used or not all columns were selected.
        /// </summary>
        /// <param name="source">The object to add the extension method to.</param>
        /// <param name="dataRecord">The <see cref="IDataRecord"/> to read the values from. Must already be ready to be read from.</param>
        public static void ReadValues(this WorldStatsQuestAcceptTable source, IDataRecord dataRecord)
        {
            Int32 i;

            i = dataRecord.GetOrdinal("id");

            source.ID = dataRecord.GetUInt32(i);

            i = dataRecord.GetOrdinal("map_id");

            source.MapID = (Nullable <MapID>)(dataRecord.IsDBNull(i) ? (ushort?)null : dataRecord.GetUInt16(i));

            i = dataRecord.GetOrdinal("quest_id");

            source.QuestID = (QuestID)dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("user_id");

            source.UserID = (CharacterID)dataRecord.GetInt32(i);

            i = dataRecord.GetOrdinal("when");

            source.When = dataRecord.GetDateTime(i);

            i = dataRecord.GetOrdinal("x");

            source.X = dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("y");

            source.Y = dataRecord.GetUInt16(i);
        }
/// <summary>
/// Reads the values from an <see cref="IDataRecord"/> and assigns the read values to this
/// object's properties. The database column's name is used to as the key, so the value
/// will not be found if any aliases are used or not all columns were selected.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataRecord"/> to read the values from. Must already be ready to be read from.</param>
        public static void ReadValues(this WorldStatsQuestAcceptTable source, System.Data.IDataRecord dataRecord)
        {
            System.Int32 i;

            i = dataRecord.GetOrdinal("id");

            source.ID = (System.UInt32)(System.UInt32) dataRecord.GetUInt32(i);

            i = dataRecord.GetOrdinal("map_id");

            source.MapID = (System.Nullable <NetGore.World.MapID>)(System.Nullable <NetGore.World.MapID>)(dataRecord.IsDBNull(i) ? (System.Nullable <System.UInt16>)null : dataRecord.GetUInt16(i));

            i = dataRecord.GetOrdinal("quest_id");

            source.QuestID = (NetGore.Features.Quests.QuestID)(NetGore.Features.Quests.QuestID) dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("user_id");

            source.UserID = (DemoGame.CharacterID)(DemoGame.CharacterID) dataRecord.GetInt32(i);

            i = dataRecord.GetOrdinal("when");

            source.When = (System.DateTime)(System.DateTime) dataRecord.GetDateTime(i);

            i = dataRecord.GetOrdinal("x");

            source.X = (System.UInt16)(System.UInt16) dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("y");

            source.Y = (System.UInt16)(System.UInt16) dataRecord.GetUInt16(i);
        }
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
        public static void TryReadValues(this WorldStatsQuestAcceptTable source, System.Data.IDataRecord dataRecord)
        {
            for (int i = 0; i < dataRecord.FieldCount; i++)
            {
                switch (dataRecord.GetName(i))
                {
                case "id":
                    source.ID = (System.UInt32)(System.UInt32) dataRecord.GetUInt32(i);
                    break;


                case "map_id":
                    source.MapID = (System.Nullable <NetGore.World.MapID>)(System.Nullable <NetGore.World.MapID>)(dataRecord.IsDBNull(i) ? (System.Nullable <System.UInt16>)null : dataRecord.GetUInt16(i));
                    break;


                case "quest_id":
                    source.QuestID = (NetGore.Features.Quests.QuestID)(NetGore.Features.Quests.QuestID) dataRecord.GetUInt16(i);
                    break;


                case "user_id":
                    source.UserID = (DemoGame.CharacterID)(DemoGame.CharacterID) dataRecord.GetInt32(i);
                    break;


                case "when":
                    source.When = (System.DateTime)(System.DateTime) dataRecord.GetDateTime(i);
                    break;


                case "x":
                    source.X = (System.UInt16)(System.UInt16) dataRecord.GetUInt16(i);
                    break;


                case "y":
                    source.Y = (System.UInt16)(System.UInt16) dataRecord.GetUInt16(i);
                    break;
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
        /// object's properties. Unlike ReadValues(), this method not only doesn't require
        /// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
        /// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
        /// Because of this, you need to be careful when using this method because values
        /// can easily be skipped without any indication.
        /// </summary>
        /// <param name="source">The object to add the extension method to.</param>
        /// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
        public static void TryReadValues(this WorldStatsQuestAcceptTable source, IDataRecord dataRecord)
        {
            for (var i = 0; i < dataRecord.FieldCount; i++)
            {
                switch (dataRecord.GetName(i))
                {
                case "id":
                    source.ID = dataRecord.GetUInt32(i);
                    break;

                case "map_id":
                    source.MapID = (Nullable <MapID>)(dataRecord.IsDBNull(i) ? (ushort?)null : dataRecord.GetUInt16(i));
                    break;

                case "quest_id":
                    source.QuestID = (QuestID)dataRecord.GetUInt16(i);
                    break;

                case "user_id":
                    source.UserID = (CharacterID)dataRecord.GetInt32(i);
                    break;

                case "when":
                    source.When = dataRecord.GetDateTime(i);
                    break;

                case "x":
                    source.X = dataRecord.GetUInt16(i);
                    break;

                case "y":
                    source.Y = dataRecord.GetUInt16(i);
                    break;
                }
            }
        }