/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="LCRBlackListRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="LCRBlackListRow"/> object.</returns> protected virtual LCRBlackListRow MapRow(DataRow row) { LCRBlackListRow mappedObject = new LCRBlackListRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Routing_plan_id" dataColumn = dataTable.Columns["Routing_plan_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Routing_plan_id = (int)row[dataColumn]; } // Column "Route_id" dataColumn = dataTable.Columns["Route_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Route_id = (int)row[dataColumn]; } // Column "Carrier_acct_id" dataColumn = dataTable.Columns["Carrier_acct_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Carrier_acct_id = (short)row[dataColumn]; } // Column "Version" dataColumn = dataTable.Columns["Version"]; if (!row.IsNull(dataColumn)) { mappedObject.Version = (int)row[dataColumn]; } return(mappedObject); }
/// <summary> /// Adds a new record into the <c>LCRBlackList</c> table. /// </summary> /// <param name="value">The <see cref="LCRBlackListRow"/> object to be inserted.</param> public virtual void Insert(LCRBlackListRow value) { string sqlStr = "INSERT INTO [dbo].[LCRBlackList] (" + "[routing_plan_id], " + "[route_id], " + "[carrier_acct_id]" + ") VALUES (" + _db.CreateSqlParameterName("Routing_plan_id") + ", " + _db.CreateSqlParameterName("Route_id") + ", " + _db.CreateSqlParameterName("Carrier_acct_id") + ")"; IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Routing_plan_id", value.Routing_plan_id); AddParameter(cmd, "Route_id", value.Route_id); AddParameter(cmd, "Carrier_acct_id", value.Carrier_acct_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="LCRBlackListRow"/> objects.</returns> protected virtual LCRBlackListRow[] 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 routing_plan_idColumnIndex = reader.GetOrdinal("routing_plan_id"); int route_idColumnIndex = reader.GetOrdinal("route_id"); int carrier_acct_idColumnIndex = reader.GetOrdinal("carrier_acct_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) { LCRBlackListRow record = new LCRBlackListRow(); recordList.Add(record); record.Routing_plan_id = Convert.ToInt32(reader.GetValue(routing_plan_idColumnIndex)); record.Route_id = Convert.ToInt32(reader.GetValue(route_idColumnIndex)); record.Carrier_acct_id = Convert.ToInt16(reader.GetValue(carrier_acct_idColumnIndex)); record.Version = Convert.ToInt32(reader.GetValue(versionColumnIndex)); if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((LCRBlackListRow[])(recordList.ToArray(typeof(LCRBlackListRow)))); }
/// <summary> /// Deletes the specified object from the <c>LCRBlackList</c> table. /// </summary> /// <param name="value">The <see cref="LCRBlackListRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(LCRBlackListRow value) { return(DeleteByPrimaryKey(value.Routing_plan_id, value.Route_id, value.Carrier_acct_id)); }