Example #1
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="EditionTypeRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="EditionTypeRow"/> object.</returns>
        protected virtual EditionTypeRow MapRow(DataRow row)
        {
            EditionTypeRow mappedObject = new EditionTypeRow();
            DataTable      dataTable    = row.Table;
            DataColumn     dataColumn;

            // Column "EditionType_ID"
            dataColumn = dataTable.Columns["EditionType_ID"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.EditionType_ID = (int)row[dataColumn];
            }
            // Column "EditionName"
            dataColumn = dataTable.Columns["EditionName"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.EditionName = (string)row[dataColumn];
            }
            // Column "EditionDescription"
            dataColumn = dataTable.Columns["EditionDescription"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.EditionDescription = (string)row[dataColumn];
            }
            // Column "EditionDisplayURL"
            dataColumn = dataTable.Columns["EditionDisplayURL"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.EditionDisplayURL = (string)row[dataColumn];
            }
            return(mappedObject);
        }
Example #2
0
        /// <summary>
        /// Reads data from the provided data reader and returns
        /// an array of mapped objects.
        /// </summary>
        /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param>
        /// <param name="startIndex">The index of the first record to map.</param>
        /// <param name="length">The number of records to map.</param>
        /// <param name="totalRecordCount">A reference parameter that returns the total number
        /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param>
        /// <returns>An array of <see cref="EditionTypeRow"/> objects.</returns>
        protected virtual EditionTypeRow[] MapRecords(IDataReader reader,
                                                      int startIndex, int length, ref int totalRecordCount)
        {
            if (0 > startIndex)
            {
                throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero.");
            }
            if (0 > length)
            {
                throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero.");
            }

            int editionType_IDColumnIndex     = reader.GetOrdinal("EditionType_ID");
            int editionNameColumnIndex        = reader.GetOrdinal("EditionName");
            int editionDescriptionColumnIndex = reader.GetOrdinal("EditionDescription");
            int editionDisplayURLColumnIndex  = reader.GetOrdinal("EditionDisplayURL");

            System.Collections.ArrayList recordList = new System.Collections.ArrayList();
            int ri = -startIndex;

            while (reader.Read())
            {
                ri++;
                if (ri > 0 && ri <= length)
                {
                    EditionTypeRow record = new EditionTypeRow();
                    recordList.Add(record);

                    record.EditionType_ID = Convert.ToInt32(reader.GetValue(editionType_IDColumnIndex));
                    if (!reader.IsDBNull(editionNameColumnIndex))
                    {
                        record.EditionName = Convert.ToString(reader.GetValue(editionNameColumnIndex));
                    }
                    if (!reader.IsDBNull(editionDescriptionColumnIndex))
                    {
                        record.EditionDescription = Convert.ToString(reader.GetValue(editionDescriptionColumnIndex));
                    }
                    if (!reader.IsDBNull(editionDisplayURLColumnIndex))
                    {
                        record.EditionDisplayURL = Convert.ToString(reader.GetValue(editionDisplayURLColumnIndex));
                    }

                    if (ri == length && 0 != totalRecordCount)
                    {
                        break;
                    }
                }
            }

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((EditionTypeRow[])(recordList.ToArray(typeof(EditionTypeRow))));
        }
Example #3
0
        /// <summary>
        /// Updates a record in the <c>EditionType</c> table.
        /// </summary>
        /// <param name="value">The <see cref="EditionTypeRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(EditionTypeRow value)
        {
            string sqlStr = "UPDATE [dbo].[EditionType] SET " +
                            "[EditionName]=" + _db.CreateSqlParameterName("@EditionName") + ", " +
                            "[EditionDescription]=" + _db.CreateSqlParameterName("@EditionDescription") + ", " +
                            "[EditionDisplayURL]=" + _db.CreateSqlParameterName("@EditionDisplayURL") +
                            " WHERE " +
                            "[EditionType_ID]=" + _db.CreateSqlParameterName("@EditionType_ID");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "@EditionName", value.EditionName);
            AddParameter(cmd, "@EditionDescription", value.EditionDescription);
            AddParameter(cmd, "@EditionDisplayURL", value.EditionDisplayURL);
            AddParameter(cmd, "@EditionType_ID", value.EditionType_ID);
            return(0 != cmd.ExecuteNonQuery());
        }
Example #4
0
        /// <summary>
        /// Adds a new record into the <c>EditionType</c> table.
        /// </summary>
        /// <param name="value">The <see cref="EditionTypeRow"/> object to be inserted.</param>
        public virtual void Insert(EditionTypeRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[EditionType] (" +
                            "[EditionName], " +
                            "[EditionDescription], " +
                            "[EditionDisplayURL]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("@EditionName") + ", " +
                            _db.CreateSqlParameterName("@EditionDescription") + ", " +
                            _db.CreateSqlParameterName("@EditionDisplayURL") + ");SELECT @@IDENTITY";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "@EditionName", value.EditionName);
            AddParameter(cmd, "@EditionDescription", value.EditionDescription);
            AddParameter(cmd, "@EditionDisplayURL", value.EditionDisplayURL);
            value.EditionType_ID = Convert.ToInt32(cmd.ExecuteScalar());
        }
Example #5
0
 /// <summary>
 /// Deletes the specified object from the <c>EditionType</c> table.
 /// </summary>
 /// <param name="value">The <see cref="EditionTypeRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(EditionTypeRow value)
 {
     return(DeleteByPrimaryKey(value.EditionType_ID));
 }