Beispiel #1
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 GuildEventTable source, System.Data.IDataRecord dataRecord)
        {
            for (int i = 0; i < dataRecord.FieldCount; i++)
            {
                switch (dataRecord.GetName(i))
                {
                case "arg0":
                    source.Arg0 = (System.String)(System.String)(dataRecord.IsDBNull(i) ? (System.String)null : dataRecord.GetString(i));
                    break;


                case "arg1":
                    source.Arg1 = (System.String)(System.String)(dataRecord.IsDBNull(i) ? (System.String)null : dataRecord.GetString(i));
                    break;


                case "arg2":
                    source.Arg2 = (System.String)(System.String)(dataRecord.IsDBNull(i) ? (System.String)null : dataRecord.GetString(i));
                    break;


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


                case "created":
                    source.Created = (System.DateTime)(System.DateTime) dataRecord.GetDateTime(i);
                    break;


                case "event_id":
                    source.EventID = (System.Byte)(System.Byte) dataRecord.GetByte(i);
                    break;


                case "guild_id":
                    source.GuildID = (NetGore.Features.Guilds.GuildID)(NetGore.Features.Guilds.GuildID) dataRecord.GetUInt16(i);
                    break;


                case "id":
                    source.ID = (System.Int32)(System.Int32) dataRecord.GetInt32(i);
                    break;


                case "target_character_id":
                    source.TargetCharacterID = (System.Nullable <DemoGame.CharacterID>)(System.Nullable <DemoGame.CharacterID>)(dataRecord.IsDBNull(i) ? (System.Nullable <System.Int32>)null : dataRecord.GetInt32(i));
                    break;
                }
            }
        }
Beispiel #2
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 GuildEventTable source, IDataRecord dataRecord)
        {
            for (var i = 0; i < dataRecord.FieldCount; i++)
            {
                switch (dataRecord.GetName(i))
                {
                case "arg0":
                    source.Arg0 = (dataRecord.IsDBNull(i) ? null : dataRecord.GetString(i));
                    break;

                case "arg1":
                    source.Arg1 = (dataRecord.IsDBNull(i) ? null : dataRecord.GetString(i));
                    break;

                case "arg2":
                    source.Arg2 = (dataRecord.IsDBNull(i) ? null : dataRecord.GetString(i));
                    break;

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

                case "created":
                    source.Created = dataRecord.GetDateTime(i);
                    break;

                case "event_id":
                    source.EventID = dataRecord.GetByte(i);
                    break;

                case "guild_id":
                    source.GuildID = (GuildID)dataRecord.GetUInt16(i);
                    break;

                case "id":
                    source.ID = dataRecord.GetInt32(i);
                    break;

                case "target_character_id":
                    source.TargetCharacterID = (CharacterID?)(dataRecord.IsDBNull(i) ? (int?)null : dataRecord.GetInt32(i));
                    break;
                }
            }
        }
Beispiel #3
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 GuildEventTable source, System.Data.IDataRecord dataRecord)
        {
            System.Int32 i;

            i = dataRecord.GetOrdinal("arg0");

            source.Arg0 = (System.String)(System.String)(dataRecord.IsDBNull(i) ? (System.String)null : dataRecord.GetString(i));

            i = dataRecord.GetOrdinal("arg1");

            source.Arg1 = (System.String)(System.String)(dataRecord.IsDBNull(i) ? (System.String)null : dataRecord.GetString(i));

            i = dataRecord.GetOrdinal("arg2");

            source.Arg2 = (System.String)(System.String)(dataRecord.IsDBNull(i) ? (System.String)null : dataRecord.GetString(i));

            i = dataRecord.GetOrdinal("character_id");

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

            i = dataRecord.GetOrdinal("created");

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

            i = dataRecord.GetOrdinal("event_id");

            source.EventID = (System.Byte)(System.Byte) dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("guild_id");

            source.GuildID = (NetGore.Features.Guilds.GuildID)(NetGore.Features.Guilds.GuildID) dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("id");

            source.ID = (System.Int32)(System.Int32) dataRecord.GetInt32(i);

            i = dataRecord.GetOrdinal("target_character_id");

            source.TargetCharacterID = (System.Nullable <DemoGame.CharacterID>)(System.Nullable <DemoGame.CharacterID>)(dataRecord.IsDBNull(i) ? (System.Nullable <System.Int32>)null : dataRecord.GetInt32(i));
        }
Beispiel #4
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 GuildEventTable source, IDataRecord dataRecord)
        {
            Int32 i;

            i = dataRecord.GetOrdinal("arg0");

            source.Arg0 = (dataRecord.IsDBNull(i) ? null : dataRecord.GetString(i));

            i = dataRecord.GetOrdinal("arg1");

            source.Arg1 = (dataRecord.IsDBNull(i) ? null : dataRecord.GetString(i));

            i = dataRecord.GetOrdinal("arg2");

            source.Arg2 = (dataRecord.IsDBNull(i) ? null : dataRecord.GetString(i));

            i = dataRecord.GetOrdinal("character_id");

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

            i = dataRecord.GetOrdinal("created");

            source.Created = dataRecord.GetDateTime(i);

            i = dataRecord.GetOrdinal("event_id");

            source.EventID = dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("guild_id");

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

            i = dataRecord.GetOrdinal("id");

            source.ID = dataRecord.GetInt32(i);

            i = dataRecord.GetOrdinal("target_character_id");

            source.TargetCharacterID = (CharacterID?)(dataRecord.IsDBNull(i) ? (int?)null : dataRecord.GetInt32(i));
        }