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

            // Column "StatusId"
            dataColumn = dataTable.Columns["StatusId"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.StatusId = (int)row[dataColumn];
            }
            // Column "StatusName"
            dataColumn = dataTable.Columns["StatusName"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.StatusName = (string)row[dataColumn];
            }
            // Column "Active"
            dataColumn = dataTable.Columns["Active"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Active = (bool)row[dataColumn];
            }
            return(mappedObject);
        }
Esempio n. 2
0
        /// <summary>
        /// Updates a record in the <c>lkpStatus</c> table.
        /// </summary>
        /// <param name="value">The <see cref="lkpStatusRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(lkpStatusRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._lkpStatus_Update", true);

            AddParameter(cmd, "StatusName", value.StatusName);
            AddParameter(cmd, "Active", value.Active);
            AddParameter(cmd, "StatusId", value.StatusId);
            return(0 != cmd.ExecuteNonQuery());
        }
Esempio n. 3
0
        /// <summary>
        /// Adds a new record into the <c>lkpStatus</c> table.
        /// </summary>
        /// <param name="value">The <see cref="lkpStatusRow"/> object to be inserted.</param>
        public virtual void Insert(lkpStatusRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._lkpStatus_Insert", true);

            AddParameter(cmd, "StatusId", value.StatusId);
            AddParameter(cmd, "StatusName", value.StatusName);
            AddParameter(cmd, "Active", value.Active);
            cmd.ExecuteNonQuery();
        }
Esempio n. 4
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="lkpStatusRow"/> objects.</returns>
        protected virtual lkpStatusRow[] 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 statusIdColumnIndex   = reader.GetOrdinal("StatusId");
            int statusNameColumnIndex = reader.GetOrdinal("StatusName");
            int activeColumnIndex     = reader.GetOrdinal("Active");

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

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

                    record.StatusId   = Convert.ToInt32(reader.GetValue(statusIdColumnIndex));
                    record.StatusName = Convert.ToString(reader.GetValue(statusNameColumnIndex));
                    record.Active     = Convert.ToBoolean(reader.GetValue(activeColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((lkpStatusRow[])(recordList.ToArray(typeof(lkpStatusRow))));
        }
Esempio n. 5
0
 /// <summary>
 /// Deletes the specified object from the <c>lkpStatus</c> table.
 /// </summary>
 /// <param name="value">The <see cref="lkpStatusRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(lkpStatusRow value)
 {
     return(DeleteByPrimaryKey(value.StatusId));
 }