/// <summary> /// Updates a record in the <c>TypeOfDayChoice</c> table. /// </summary> /// <param name="value">The <see cref="TypeOfDayChoiceRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(TypeOfDayChoiceRow value) { string sqlStr = "UPDATE [dbo].[TypeOfDayChoice] SET " + "[name]=" + _db.CreateSqlParameterName("Name") + " WHERE " + "[type_of_day_choice]=" + _db.CreateSqlParameterName("Type_of_day_choice"); IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Name", value.Name); AddParameter(cmd, "Type_of_day_choice", value.Type_of_day_choice); return(0 != cmd.ExecuteNonQuery()); }
/// <summary> /// Adds a new record into the <c>TypeOfDayChoice</c> table. /// </summary> /// <param name="value">The <see cref="TypeOfDayChoiceRow"/> object to be inserted.</param> public virtual void Insert(TypeOfDayChoiceRow value) { string sqlStr = "INSERT INTO [dbo].[TypeOfDayChoice] (" + "[type_of_day_choice], " + "[name]" + ") VALUES (" + _db.CreateSqlParameterName("Type_of_day_choice") + ", " + _db.CreateSqlParameterName("Name") + ")"; IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Type_of_day_choice", value.Type_of_day_choice); AddParameter(cmd, "Name", value.Name); cmd.ExecuteNonQuery(); }
/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="TypeOfDayChoiceRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="TypeOfDayChoiceRow"/> object.</returns> protected virtual TypeOfDayChoiceRow MapRow(DataRow row) { TypeOfDayChoiceRow mappedObject = new TypeOfDayChoiceRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Type_of_day_choice" dataColumn = dataTable.Columns["Type_of_day_choice"]; if (!row.IsNull(dataColumn)) { mappedObject.Type_of_day_choice = (byte)row[dataColumn]; } // Column "Name" dataColumn = dataTable.Columns["Name"]; if (!row.IsNull(dataColumn)) { mappedObject.Name = (string)row[dataColumn]; } return(mappedObject); }
/// <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="TypeOfDayChoiceRow"/> objects.</returns> protected virtual TypeOfDayChoiceRow[] 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 type_of_day_choiceColumnIndex = reader.GetOrdinal("type_of_day_choice"); int nameColumnIndex = reader.GetOrdinal("name"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { TypeOfDayChoiceRow record = new TypeOfDayChoiceRow(); recordList.Add(record); record.Type_of_day_choice = Convert.ToByte(reader.GetValue(type_of_day_choiceColumnIndex)); record.Name = Convert.ToString(reader.GetValue(nameColumnIndex)); if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((TypeOfDayChoiceRow[])(recordList.ToArray(typeof(TypeOfDayChoiceRow)))); }
/// <summary> /// Deletes the specified object from the <c>TypeOfDayChoice</c> table. /// </summary> /// <param name="value">The <see cref="TypeOfDayChoiceRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(TypeOfDayChoiceRow value) { return(DeleteByPrimaryKey(value.Type_of_day_choice)); }