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