/// <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="CdrExportMapDetailRow"/> objects.</returns> protected virtual CdrExportMapDetailRow[] 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 map_detail_idColumnIndex = reader.GetOrdinal("map_detail_id"); int map_idColumnIndex = reader.GetOrdinal("map_id"); int sequenceColumnIndex = reader.GetOrdinal("sequence"); int field_nameColumnIndex = reader.GetOrdinal("field_name"); int format_typeColumnIndex = reader.GetOrdinal("format_type"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { CdrExportMapDetailRow record = new CdrExportMapDetailRow(); recordList.Add(record); record.Map_detail_id = Convert.ToInt32(reader.GetValue(map_detail_idColumnIndex)); record.Map_id = Convert.ToInt32(reader.GetValue(map_idColumnIndex)); record.Sequence = Convert.ToInt32(reader.GetValue(sequenceColumnIndex)); record.Field_name = Convert.ToString(reader.GetValue(field_nameColumnIndex)); if (!reader.IsDBNull(format_typeColumnIndex)) { record.Format_type = Convert.ToString(reader.GetValue(format_typeColumnIndex)); } if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((CdrExportMapDetailRow[])(recordList.ToArray(typeof(CdrExportMapDetailRow)))); }
internal static CdrExportMapDetailDto MapToCdrExportMapDetail(CdrExportMapDetailRow pCdrExportMapDetailRow) { if (pCdrExportMapDetailRow == null) { return(null); } var _cdrExportMapDetail = new CdrExportMapDetailDto(); _cdrExportMapDetail.MapDetailId = pCdrExportMapDetailRow.Map_detail_id; _cdrExportMapDetail.MapId = pCdrExportMapDetailRow.Map_id; _cdrExportMapDetail.Sequence = pCdrExportMapDetailRow.Sequence; _cdrExportMapDetail.FieldName = pCdrExportMapDetailRow.Field_name; _cdrExportMapDetail.FormatType = pCdrExportMapDetailRow.Format_type; return(_cdrExportMapDetail); }
/// <summary> /// Updates a record in the <c>CdrExportMapDetail</c> table. /// </summary> /// <param name="value">The <see cref="CdrExportMapDetailRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(CdrExportMapDetailRow value) { string sqlStr = "UPDATE [dbo].[CdrExportMapDetail] SET " + "[map_id]=" + _db.CreateSqlParameterName("Map_id") + ", " + "[sequence]=" + _db.CreateSqlParameterName("Sequence") + ", " + "[field_name]=" + _db.CreateSqlParameterName("Field_name") + ", " + "[format_type]=" + _db.CreateSqlParameterName("Format_type") + " WHERE " + "[map_detail_id]=" + _db.CreateSqlParameterName("Map_detail_id"); IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Map_id", value.Map_id); AddParameter(cmd, "Sequence", value.Sequence); AddParameter(cmd, "Field_name", value.Field_name); AddParameter(cmd, "Format_type", value.Format_type); AddParameter(cmd, "Map_detail_id", value.Map_detail_id); return(0 != cmd.ExecuteNonQuery()); }
/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="CdrExportMapDetailRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="CdrExportMapDetailRow"/> object.</returns> protected virtual CdrExportMapDetailRow MapRow(DataRow row) { CdrExportMapDetailRow mappedObject = new CdrExportMapDetailRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Map_detail_id" dataColumn = dataTable.Columns["Map_detail_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Map_detail_id = (int)row[dataColumn]; } // Column "Map_id" dataColumn = dataTable.Columns["Map_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Map_id = (int)row[dataColumn]; } // Column "Sequence" dataColumn = dataTable.Columns["Sequence"]; if (!row.IsNull(dataColumn)) { mappedObject.Sequence = (int)row[dataColumn]; } // Column "Field_name" dataColumn = dataTable.Columns["Field_name"]; if (!row.IsNull(dataColumn)) { mappedObject.Field_name = (string)row[dataColumn]; } // Column "Format_type" dataColumn = dataTable.Columns["Format_type"]; if (!row.IsNull(dataColumn)) { mappedObject.Format_type = (string)row[dataColumn]; } return(mappedObject); }
/// <summary> /// Adds a new record into the <c>CdrExportMapDetail</c> table. /// </summary> /// <param name="value">The <see cref="CdrExportMapDetailRow"/> object to be inserted.</param> public virtual void Insert(CdrExportMapDetailRow value) { string sqlStr = "INSERT INTO [dbo].[CdrExportMapDetail] (" + "[map_detail_id], " + "[map_id], " + "[sequence], " + "[field_name], " + "[format_type]" + ") VALUES (" + _db.CreateSqlParameterName("Map_detail_id") + ", " + _db.CreateSqlParameterName("Map_id") + ", " + _db.CreateSqlParameterName("Sequence") + ", " + _db.CreateSqlParameterName("Field_name") + ", " + _db.CreateSqlParameterName("Format_type") + ")"; IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Map_detail_id", value.Map_detail_id); AddParameter(cmd, "Map_id", value.Map_id); AddParameter(cmd, "Sequence", value.Sequence); AddParameter(cmd, "Field_name", value.Field_name); AddParameter(cmd, "Format_type", value.Format_type); cmd.ExecuteNonQuery(); }
/// <summary> /// Deletes the specified object from the <c>CdrExportMapDetail</c> table. /// </summary> /// <param name="value">The <see cref="CdrExportMapDetailRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(CdrExportMapDetailRow value) { return(DeleteByPrimaryKey(value.Map_detail_id)); }