Exemplo n.º 1
0
        /// <summary>
        /// Adds a new record into the <c>tblRole</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblRoleRow"/> object to be inserted.</param>
        public virtual void Insert(tblRoleRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblRole_Insert", true);

            AddParameter(cmd, "Role", value.Role);
            value.Role_Id = Convert.ToInt32(cmd.ExecuteScalar());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates a record in the <c>tblRole</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblRoleRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(tblRoleRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblRole_Update", true);

            AddParameter(cmd, "Role", value.Role);
            AddParameter(cmd, "Role_Id", value.Role_Id);
            return(0 != cmd.ExecuteNonQuery());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="tblRoleRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="tblRoleRow"/> object.</returns>
        protected virtual tblRoleRow MapRow(DataRow row)
        {
            tblRoleRow mappedObject = new tblRoleRow();
            DataTable  dataTable    = row.Table;
            DataColumn dataColumn;

            // Column "Role_Id"
            dataColumn = dataTable.Columns["Role_Id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Role_Id = (int)row[dataColumn];
            }
            // Column "Role"
            dataColumn = dataTable.Columns["Role"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Role = (string)row[dataColumn];
            }
            return(mappedObject);
        }
Exemplo 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="tblRoleRow"/> objects.</returns>
        protected virtual tblRoleRow[] 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 role_IdColumnIndex = reader.GetOrdinal("Role_Id");
            int roleColumnIndex    = reader.GetOrdinal("Role");

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

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

                    record.Role_Id = Convert.ToInt32(reader.GetValue(role_IdColumnIndex));
                    record.Role    = Convert.ToString(reader.GetValue(roleColumnIndex));

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

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