internal static MessageAttachment getAttachmentFromReader(System.Data.IDataReader rdr, Dictionary<string, bool> columnTable)
        {
            MessageAttachment attachment = new MessageAttachment();

            if (columnTable["ATTACHMENT_ID"])
            {
                int idIndex = rdr.GetOrdinal("ATTACHMENT_ID");
                if (!rdr.IsDBNull(idIndex))
                {
                    attachment.Id = Convert.ToInt32(rdr.GetDecimal(idIndex));
                }
            }
            if (columnTable["ATTACHMENT_NAME"])
            {
                int nameIndex = rdr.GetOrdinal("ATTACHMENT_NAME");
                if (!rdr.IsDBNull(nameIndex))
                {
                    attachment.AttachmentName = rdr.GetString(nameIndex);
                }
            }
            if (columnTable["ATTACHMENT"])
            {
                int attIndex = rdr.GetOrdinal("ATTACHMENT");
                if (!rdr.IsDBNull(attIndex))
                {
                    // not crazy about this implementation as it appears to invoke the reader twice but the commented out code
                    // block directly below throws an exception when calling GetOracleBlob for some reason... The good thing about
                    // this solution is it should work for all IDataReader implementations and doesn't need to be cast to an OracleDataReader
                    byte[] blob = new byte[rdr.GetBytes(attIndex, 0, null, 0, Int32.MaxValue)];
                    rdr.GetBytes(attIndex, 0, blob, 0, blob.Length);
                    attachment.SmFile = blob;
                    //if (rdr is Oracle.DataAccess.Client.OracleDataReader)
                    //{
                    //    System.Console.WriteLine(rdr[attIndex].GetType().ToString());
                    //    Oracle.DataAccess.Types.OracleBlob blob = ((Oracle.DataAccess.Client.OracleDataReader)rdr).GetOracleBlob(attIndex);
                    //    byte[] buf = new byte[blob.Length];
                    //    blob.Read(buf, 0, Convert.ToInt32(blob.Length));
                    //    attachment.SmFile = buf;
                    //}
                }
            }
            if (columnTable["MIME_TYPE"])
            {
                int mimeTypeIndex = rdr.GetOrdinal("MIME_TYPE");
                if (!rdr.IsDBNull(mimeTypeIndex))
                {
                    attachment.MimeType = rdr.GetString(mimeTypeIndex);
                }
            }
            if (columnTable["ATTOPLOCK"])
            {
                int oplockIndex = rdr.GetOrdinal("ATTOPLOCK");
                if (!rdr.IsDBNull(oplockIndex))
                {
                    attachment.Oplock = Convert.ToInt32(rdr.GetDecimal(oplockIndex));
                }
            }

            return attachment;
        }
Example #2
0
 private static hierarchy2b ORM_CreateProxy(System.Data.IDataReader result, System.Collections.Generic.IDictionary<string, int> ordinals)
 {
     return new hierarchy2b()
     {
         pid = result.IsDBNull(ordinals["pid"]) ? 0 : result.GetInt64(ordinals["pid"]),
         fid = result.IsDBNull(ordinals["fid"]) ? 0 : result.GetInt64(ordinals["fid"]),
         textfield = result.IsDBNull(ordinals["textfield"]) ? null : result.GetString(ordinals["textfield"])
     };
 }
Example #3
0
        /// <summary>
        /// Permet remplir les propriétés de mappage de l'entité admin.
        /// </summary>
        /// <param name="reader">reader contenant les données.</param>
        /// <returns>Un objet adminDTO.</returns>
        public override Mappage.DTOBase populateDTO(System.Data.SqlClient.SqlDataReader reader)
        {
            typeDTO type = new typeDTO();

            if (!reader.IsDBNull(ordTypeGuid)) { type.typeGuid = reader.GetGuid(ordTypeGuid); }
            if (!reader.IsDBNull(ordTypeType)) { type.typeType = reader.GetString(ordTypeType); }

            type.isNew = false;
            return type;
        }
        /// <summary>
        /// Permet de remplir les propriétés de mappage de l'entité difficulté.
        /// </summary>
        /// <param name="reader">reader contenant les données.</param>
        /// <returns>Un objet difficulteDTO</returns>
        public override Mappage.DTOBase populateDTO(System.Data.SqlClient.SqlDataReader reader)
        {
            difficulteDTO difficulte = new difficulteDTO();

            if (!reader.IsDBNull(ordDifficulteGuid)) { difficulte.difficulteGuid = reader.GetGuid(ordDifficulteGuid); }
            if (!reader.IsDBNull(ordDifficulteNiveau)) { difficulte.difficulteNiveau = reader.GetString(ordDifficulteNiveau); }

            difficulte.isNew = false;
            return difficulte;
        }
Example #5
0
 public override DTOBase PopulateDTO(System.Data.IDataReader reader)
 {
     var credential = base.PopulateId(reader, new Credential());
     if (!reader.IsDBNull(_ordinals.EmailAddress)) { credential.EmailAddress = reader.GetString(_ordinals.EmailAddress); }
     if (!reader.IsDBNull(_ordinals.Salt)) { credential.Salt = reader.GetString(_ordinals.Salt); }
     if (!reader.IsDBNull(_ordinals.PasswordHash)) { credential.PasswordHash = reader.GetString(_ordinals.PasswordHash); }
     if (!reader.IsDBNull(_ordinals.CreateDateTimeUtc)) { credential.CreateDateTimeUtc = reader.GetDateTime(_ordinals.CreateDateTimeUtc); }
     credential.IsNew = false;
     return credential;
 }
Example #6
0
        /// <summary>
        /// Permet de remplir les propriétés de mappage de l'entité highscore.
        /// </summary>
        /// <param name="reader">reader contenant les données.</param>
        /// <returns>Un objet adminDTO.</returns>
        public override Mappage.DTOBase populateDTO(System.Data.SqlClient.SqlDataReader reader)
        {
            highscoreDTO highscore = new highscoreDTO();

            if (!reader.IsDBNull(ordHighscoreGuid)) { highscore.highscoreGuid = reader.GetGuid(ordHighscoreGuid); }
            if (!reader.IsDBNull(ordHighscorePseudo)) { highscore.highscorePseudo = reader.GetString(ordHighscorePseudo); }
            if (!reader.IsDBNull(ordHighscoreScore)) { highscore.highscoreScore = reader.GetInt32(ordHighscoreScore); }

            highscore.isNew = false;
            return highscore;
        }
Example #7
0
        /// <summary>
        /// Permet remplir les propriétés de mappage de l'entité admin.
        /// </summary>
        /// <param name="reader">reader contenant les données.</param>
        /// <returns>Un objet adminDTO.</returns>
        public override Mappage.DTOBase populateDTO(System.Data.SqlClient.SqlDataReader reader)
        {
            adminDTO admin = new adminDTO();

            if (!reader.IsDBNull(ordAdminGuid)) { admin.adminGuid = reader.GetGuid(ordAdminGuid); }
            if (!reader.IsDBNull(ordAdminLogin)) { admin.adminLogin = reader.GetString(ordAdminLogin); }
            if (!reader.IsDBNull(ordAdminPassword)) { admin.adminPassword = reader.GetString(ordAdminPassword); }

            admin.isNew = false;
            return admin;
        }
Example #8
0
        /// <summary>
        /// Permet remplir les propriétés de mappage de l'entité réponse.
        /// </summary>
        /// <param name="reader">reader contenant les données.</param>
        /// <returns>Un objet reponseDTO.</returns>
        public override Mappage.DTOBase populateDTO(System.Data.SqlClient.SqlDataReader reader)
        {
            reponseDTO reponse = new reponseDTO();

            if (!reader.IsDBNull(ordReponseGuid)) { reponse.reponseGuid = reader.GetGuid(ordReponseGuid); }
            if (!reader.IsDBNull(ordReponseIntitule)) { reponse.reponseIntitule = reader.GetString(ordReponseIntitule); }
            if (!reader.IsDBNull(ordReponseJuste)) { reponse.reponseJuste = reader.GetBoolean(ordReponseJuste); }
            if (!reader.IsDBNull(ordReponseQuestionGuid)) { reponse.reponseQuestionGuid = reader.GetInt32(ordReponseQuestionGuid); }

            reponse.isNew = false;
            return reponse;
        }
Example #9
0
        /// <summary>
        /// Permet remplir les propriétés de mappage de l'entité métier.
        /// </summary>
        /// <param name="reader">reader contenant les données.</param>
        /// <returns>Un objet metierDTO.</returns>
        public override Mappage.DTOBase populateDTO(System.Data.SqlClient.SqlDataReader reader)
        {
            metierDTO metier = new metierDTO();

            if (!reader.IsDBNull(ordMetierGuid)) { metier.metierGuid = reader.GetGuid(ordMetierGuid); }
            if (!reader.IsDBNull(ordMetierNom)) { metier.metierNom = reader.GetString(ordMetierNom); }
            if (!reader.IsDBNull(ordMetierFiche)) { metier.metierFiche = reader.GetString(ordMetierFiche); }
            if (!reader.IsDBNull(ordMetierScoreReseau)) { metier.metierScoreReseau = reader.GetInt32(ordMetierScoreReseau); }
            if (!reader.IsDBNull(ordMetierScoreLogiciel)) { metier.metierScorelogiciel = reader.GetInt32(ordMetierScoreLogiciel); }

            metier.isNew = false;
            return metier;
        }
Example #10
0
        /// <summary>
        /// Permet de remplir les propriétés de mappage de l'entité question.
        /// </summary>
        /// <param name="reader">reader contenant les données.</param>
        /// <returns>Un objet questionDTO.</returns>
        public override Mappage.DTOBase populateDTO(System.Data.SqlClient.SqlDataReader reader)
        {
            questionDTO question = new questionDTO(); // On crée un nouveau questionDTO. Etant donné qu'il hérite de DTOBase on peut l'utiliser comme valeur de retour.

            // On utilise l'ordinal correspondant pour s'assurer que la valeur retournée par le reader n'est pas null.
            // Si cette valeur n'est pas null, on utilise getXXX typée du reader pour obtenir la valeur.
            if (!reader.IsDBNull(ordQuestionGuid)) { question.questionGuid = reader.GetGuid(ordQuestionGuid); }
            if (!reader.IsDBNull(ordQuestionIntitule)) { question.questionIntitule = reader.GetString(ordQuestionIntitule); }
            if (!reader.IsDBNull(ordQuestionReponseGuid)) { question.questionReponseGuid = reader.GetInt32(ordQuestionReponseGuid); }
            if (!reader.IsDBNull(ordQuestionDifficulteGuid)) { question.questionDifficulteGuid = reader.GetInt32(ordQuestionDifficulteGuid); }
            if (!reader.IsDBNull(ordQuestionTypeGuid)) { question.questionTypeGuid = reader.GetInt32(ordQuestionTypeGuid); }

            question.isNew = false;
            return question;
        }
/// <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 AccountBanTable source, System.Data.IDataRecord dataRecord)
{
System.Int32 i;

i = dataRecord.GetOrdinal("account_id");

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

i = dataRecord.GetOrdinal("end_time");

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

i = dataRecord.GetOrdinal("expired");

source.Expired = (System.Boolean)(System.Boolean)dataRecord.GetBoolean(i);

i = dataRecord.GetOrdinal("id");

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

i = dataRecord.GetOrdinal("issued_by");

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

i = dataRecord.GetOrdinal("reason");

source.Reason = (System.String)(System.String)dataRecord.GetString(i);

i = dataRecord.GetOrdinal("start_time");

source.StartTime = (System.DateTime)(System.DateTime)dataRecord.GetDateTime(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="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 WorldStatsUserConsumeItemTable source, System.Data.IDataRecord dataRecord)
{
System.Int32 i;

i = dataRecord.GetOrdinal("id");

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

i = dataRecord.GetOrdinal("item_template_id");

source.ItemTemplateID = (DemoGame.ItemTemplateID)(DemoGame.ItemTemplateID)dataRecord.GetUInt16(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("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);
}
Example #14
0
        public override object NullSafeGet(System.Data.IDataReader rs, string name)
        {
            int index = rs.GetOrdinal(name);

            if( rs.IsDBNull(index) )
            {
                if ( log.IsDebugEnabled )
                {
                    log.Debug("returning null as column: " + name);
                }

                return NullValue; //this value is determined by the subclass.
            }
            else
            {
                object val = null;
                try
                {
                    val = Get(rs, index);
                }
                catch(System.InvalidCastException ice)
                {
                    throw new ADOException(
                        "Could not cast the value in field " + name + " to the Type " + this.GetType().Name +
                        ".  Please check to make sure that the mapping is correct and that your DataProvider supports this Data Type.", ice);
                }

                if ( log.IsDebugEnabled )
                {
                    log.Debug("returning '" + ToString(val) + "' as column: " + name);
                }

                return val;
            }
        }
/// <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 WorldStatsNpcKillUserTable 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("npc_template_id");

source.NPCTemplateID = (System.Nullable<DemoGame.CharacterTemplateID>)(System.Nullable<DemoGame.CharacterTemplateID>)(dataRecord.IsDBNull(i) ? (System.Nullable<System.UInt16>)null : dataRecord.GetUInt16(i));

i = dataRecord.GetOrdinal("npc_x");

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

i = dataRecord.GetOrdinal("npc_y");

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

i = dataRecord.GetOrdinal("user_id");

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

i = dataRecord.GetOrdinal("user_level");

source.UserLevel = (System.Int16)(System.Int16)dataRecord.GetInt16(i);

i = dataRecord.GetOrdinal("user_x");

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

i = dataRecord.GetOrdinal("user_y");

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

i = dataRecord.GetOrdinal("when");

source.When = (System.DateTime)(System.DateTime)dataRecord.GetDateTime(i);
}
Example #16
0
 public float PreencheAtributo(System.Data.IDataReader lDataReader, int NumeroColuna, float Atributo)
 {
     if ((lDataReader.IsDBNull(NumeroColuna) == true))
     {
         return float.MinValue;
     }
     else
     {
         return lDataReader.GetFloat(NumeroColuna);
     }
 }
Example #17
0
 public DateTime PreencheAtributo(System.Data.IDataReader lDataReader, int NumeroColuna, System.DateTime Atributo)
 {
     if ((lDataReader.IsDBNull(NumeroColuna) == true))
     {
         return DateTime.MinValue;
     }
     else
     {
         return lDataReader.GetDateTime(NumeroColuna);
     }
 }
Example #18
0
 public string PreencheAtributo(System.Data.IDataReader lDataReader, int NumeroColuna, string Atributo)
 {
     if ((lDataReader.IsDBNull(NumeroColuna) == true))
     {
         return null;
     }
     else
     {
         return lDataReader.GetString(NumeroColuna);
     }
 }
Example #19
0
 public short PreencheAtributo(System.Data.IDataReader lDataReader, int NumeroColuna, short Atributo)
 {
     if ((lDataReader.IsDBNull(NumeroColuna) == true))
     {
         return Int16.MinValue;
     }
     else
     {
         return lDataReader.GetInt16(NumeroColuna);
     }
 }
Example #20
0
 public long PreencheAtributo(System.Data.IDataReader lDataReader, int NumeroColuna, long Atributo)
 {
     if ((lDataReader.IsDBNull(NumeroColuna) == true))
     {
         return Int64.MinValue;
     }
     else
     {
         return lDataReader.GetInt64(NumeroColuna);
     }
 }
/// <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));
}
Example #22
0
 public object NullSafeGet(System.Data.IDataReader rs, string[] names, object owner)
 {
     HashSet<Guid> result = new HashSet<Guid>();
     Int32 index = rs.GetOrdinal(names[0]);
     if (rs.IsDBNull(index) || String.IsNullOrEmpty((String)rs[index]))
         return result;
     foreach (String s in ((String)rs[index]).Split(cStringSeparator))
     {
         var id = Guid.Parse(s);
         result.Add(id);
     }
     return result;
 }
Example #23
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 MapSpawnTable source, System.Data.IDataRecord dataRecord)
{
System.Int32 i;

i = dataRecord.GetOrdinal("amount");

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

i = dataRecord.GetOrdinal("character_template_id");

source.CharacterTemplateID = (DemoGame.CharacterTemplateID)(DemoGame.CharacterTemplateID)dataRecord.GetUInt16(i);

i = dataRecord.GetOrdinal("height");

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

i = dataRecord.GetOrdinal("id");

source.ID = (DemoGame.MapSpawnValuesID)(DemoGame.MapSpawnValuesID)dataRecord.GetInt32(i);

i = dataRecord.GetOrdinal("map_id");

source.MapID = (NetGore.World.MapID)(NetGore.World.MapID)dataRecord.GetUInt16(i);

i = dataRecord.GetOrdinal("width");

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

i = dataRecord.GetOrdinal("x");

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

i = dataRecord.GetOrdinal("y");

source.Y = (System.Nullable<System.UInt16>)(System.Nullable<System.UInt16>)(dataRecord.IsDBNull(i) ? (System.Nullable<System.UInt16>)null : 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 WorldStatsUserShoppingTable source, System.Data.IDataRecord dataRecord)
{
System.Int32 i;

i = dataRecord.GetOrdinal("amount");

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

i = dataRecord.GetOrdinal("character_id");

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

i = dataRecord.GetOrdinal("cost");

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

i = dataRecord.GetOrdinal("id");

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

i = dataRecord.GetOrdinal("item_template_id");

source.ItemTemplateID = (System.Nullable<DemoGame.ItemTemplateID>)(System.Nullable<DemoGame.ItemTemplateID>)(dataRecord.IsDBNull(i) ? (System.Nullable<System.UInt16>)null : dataRecord.GetUInt16(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("sale_type");

source.SaleType = (System.SByte)(System.SByte)dataRecord.GetSByte(i);

i = dataRecord.GetOrdinal("shop_id");

source.ShopID = (NetGore.Features.Shops.ShopID)(NetGore.Features.Shops.ShopID)dataRecord.GetUInt16(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="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 AccountCharacterTable source, System.Data.IDataRecord dataRecord)
{
System.Int32 i;

i = dataRecord.GetOrdinal("account_id");

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

i = dataRecord.GetOrdinal("character_id");

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

i = dataRecord.GetOrdinal("time_deleted");

source.TimeDeleted = (System.Nullable<System.DateTime>)(System.Nullable<System.DateTime>)(dataRecord.IsDBNull(i) ? (System.Nullable<System.DateTime>)null : dataRecord.GetDateTime(i));
}
Example #26
0
		public object NullSafeGet(System.Data.IDataReader rs, string[] names, object owner)
		{
			Int32 index = rs.GetOrdinal(names[0]);
			if (rs.IsDBNull(index))
			{
				return null;
			}

			try
			{
				return IPAddress.Parse(rs[index].ToString());
			}
			catch (FormatException)
			{
				//The uri is malformed, maybe it is worth to doing something else.
				return null;
			}
		}
Example #27
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 AccountTable source, System.Data.IDataRecord dataRecord)
{
System.Int32 i;

i = dataRecord.GetOrdinal("creator_ip");

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

i = dataRecord.GetOrdinal("current_ip");

source.CurrentIp = (System.Nullable<System.UInt32>)(System.Nullable<System.UInt32>)(dataRecord.IsDBNull(i) ? (System.Nullable<System.UInt32>)null : dataRecord.GetUInt32(i));

i = dataRecord.GetOrdinal("email");

source.Email = (System.String)(System.String)dataRecord.GetString(i);

i = dataRecord.GetOrdinal("friends");

source.Friends = (System.String)(System.String)dataRecord.GetString(i);

i = dataRecord.GetOrdinal("id");

source.ID = (DemoGame.AccountID)(DemoGame.AccountID)dataRecord.GetInt32(i);

i = dataRecord.GetOrdinal("name");

source.Name = (System.String)(System.String)dataRecord.GetString(i);

i = dataRecord.GetOrdinal("password");

source.Password = (System.String)(System.String)dataRecord.GetString(i);

i = dataRecord.GetOrdinal("permissions");

source.Permissions = (DemoGame.UserPermissions)(DemoGame.UserPermissions)dataRecord.GetByte(i);

i = dataRecord.GetOrdinal("time_created");

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

i = dataRecord.GetOrdinal("time_last_login");

source.TimeLastLogin = (System.DateTime)(System.DateTime)dataRecord.GetDateTime(i);
}
Example #28
0
 public static double GetDouble(System.Data.SqlClient.SqlDataReader rd, string field)
 {
     var index = rd.GetOrdinal(field);
     if (index < 0)
     {
         return 0;
     }
     else
     {
         if (rd.IsDBNull(index))
         {
             return 0;
         }
         else
         {
             return rd.GetDouble(index);
         }
     }
 }
/// <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 CharacterQuestStatusTable source, System.Data.IDataRecord dataRecord)
{
System.Int32 i;

i = dataRecord.GetOrdinal("character_id");

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

i = dataRecord.GetOrdinal("completed_on");

source.CompletedOn = (System.Nullable<System.DateTime>)(System.Nullable<System.DateTime>)(dataRecord.IsDBNull(i) ? (System.Nullable<System.DateTime>)null : dataRecord.GetDateTime(i));

i = dataRecord.GetOrdinal("quest_id");

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

i = dataRecord.GetOrdinal("started_on");

source.StartedOn = (System.DateTime)(System.DateTime)dataRecord.GetDateTime(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 WorldStatsGuildUserChangeTable source, System.Data.IDataRecord dataRecord)
{
System.Int32 i;

i = dataRecord.GetOrdinal("guild_id");

source.GuildID = (System.Nullable<NetGore.Features.Guilds.GuildID>)(System.Nullable<NetGore.Features.Guilds.GuildID>)(dataRecord.IsDBNull(i) ? (System.Nullable<System.UInt16>)null : dataRecord.GetUInt16(i));

i = dataRecord.GetOrdinal("id");

source.ID = (System.UInt32)(System.UInt32)dataRecord.GetUInt32(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);
}