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

            // Column "SacntionID"
            dataColumn = dataTable.Columns["SacntionID"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.SacntionID = (int)row[dataColumn];
            }
            // Column "SacntionName"
            dataColumn = dataTable.Columns["SacntionName"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.SacntionName = (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>lkpSanction</c> table.
        /// </summary>
        /// <param name="value">The <see cref="lkpSanctionRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(lkpSanctionRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._lkpSanction_Update", true);

            AddParameter(cmd, "SacntionName", value.SacntionName);
            AddParameter(cmd, "Active",
                         value.IsActiveNull ? DBNull.Value : (object)value.Active);
            AddParameter(cmd, "SacntionID", value.SacntionID);
            return(0 != cmd.ExecuteNonQuery());
        }
Esempio n. 3
0
        /// <summary>
        /// Adds a new record into the <c>lkpSanction</c> table.
        /// </summary>
        /// <param name="value">The <see cref="lkpSanctionRow"/> object to be inserted.</param>
        public virtual void Insert(lkpSanctionRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._lkpSanction_Insert", true);

            AddParameter(cmd, "SacntionID", value.SacntionID);
            AddParameter(cmd, "SacntionName", value.SacntionName);
            AddParameter(cmd, "Active",
                         value.IsActiveNull ? DBNull.Value : (object)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="lkpSanctionRow"/> objects.</returns>
        protected virtual lkpSanctionRow[] 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 sacntionIDColumnIndex   = reader.GetOrdinal("SacntionID");
            int sacntionNameColumnIndex = reader.GetOrdinal("SacntionName");
            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)
                {
                    lkpSanctionRow record = new lkpSanctionRow();
                    recordList.Add(record);

                    record.SacntionID = Convert.ToInt32(reader.GetValue(sacntionIDColumnIndex));
                    if (!reader.IsDBNull(sacntionNameColumnIndex))
                    {
                        record.SacntionName = Convert.ToString(reader.GetValue(sacntionNameColumnIndex));
                    }
                    if (!reader.IsDBNull(activeColumnIndex))
                    {
                        record.Active = Convert.ToBoolean(reader.GetValue(activeColumnIndex));
                    }

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

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