示例#1
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="RoutingPlanRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="RoutingPlanRow"/> object.</returns>
        protected virtual RoutingPlanRow MapRow(DataRow row)
        {
            RoutingPlanRow mappedObject = new RoutingPlanRow();
            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 "Name"
            dataColumn = dataTable.Columns["Name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Name = (string)row[dataColumn];
            }
            // Column "Calling_plan_id"
            dataColumn = dataTable.Columns["Calling_plan_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Calling_plan_id = (int)row[dataColumn];
            }
            // Column "Virtual_switch_id"
            dataColumn = dataTable.Columns["Virtual_switch_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Virtual_switch_id = (int)row[dataColumn];
            }
            return(mappedObject);
        }
示例#2
0
        /// <summary>
        /// Updates a record in the <c>RoutingPlan</c> table.
        /// </summary>
        /// <param name="value">The <see cref="RoutingPlanRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(RoutingPlanRow value)
        {
            string sqlStr = "UPDATE [dbo].[RoutingPlan] SET " +
                            "[name]=" + _db.CreateSqlParameterName("Name") + ", " +
                            "[calling_plan_id]=" + _db.CreateSqlParameterName("Calling_plan_id") + ", " +
                            "[virtual_switch_id]=" + _db.CreateSqlParameterName("Virtual_switch_id") +
                            " WHERE " +
                            "[routing_plan_id]=" + _db.CreateSqlParameterName("Routing_plan_id");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Name", value.Name);
            AddParameter(cmd, "Calling_plan_id", value.Calling_plan_id);
            AddParameter(cmd, "Virtual_switch_id", value.Virtual_switch_id);
            AddParameter(cmd, "Routing_plan_id", value.Routing_plan_id);
            return(0 != cmd.ExecuteNonQuery());
        }
示例#3
0
        static RoutingPlanRow mapToRoutingPlanRow(RoutingPlanDto pRoutingPlan)
        {
            if (pRoutingPlan == null)
            {
                return(null);
            }

            var _routingPlanRow = new RoutingPlanRow();

            _routingPlanRow.Routing_plan_id   = pRoutingPlan.RoutingPlanId;
            _routingPlanRow.Name              = pRoutingPlan.Name;
            _routingPlanRow.Calling_plan_id   = pRoutingPlan.CallingPlanId;
            _routingPlanRow.Virtual_switch_id = pRoutingPlan.VirtualSwitchId;

            return(_routingPlanRow);
        }
示例#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="RoutingPlanRow"/> objects.</returns>
        protected virtual RoutingPlanRow[] 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 nameColumnIndex              = reader.GetOrdinal("name");
            int calling_plan_idColumnIndex   = reader.GetOrdinal("calling_plan_id");
            int virtual_switch_idColumnIndex = reader.GetOrdinal("virtual_switch_id");

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

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

                    record.Routing_plan_id   = Convert.ToInt32(reader.GetValue(routing_plan_idColumnIndex));
                    record.Name              = Convert.ToString(reader.GetValue(nameColumnIndex));
                    record.Calling_plan_id   = Convert.ToInt32(reader.GetValue(calling_plan_idColumnIndex));
                    record.Virtual_switch_id = Convert.ToInt32(reader.GetValue(virtual_switch_idColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((RoutingPlanRow[])(recordList.ToArray(typeof(RoutingPlanRow))));
        }
示例#5
0
        /// <summary>
        /// Adds a new record into the <c>RoutingPlan</c> table.
        /// </summary>
        /// <param name="value">The <see cref="RoutingPlanRow"/> object to be inserted.</param>
        public virtual void Insert(RoutingPlanRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[RoutingPlan] (" +
                            "[routing_plan_id], " +
                            "[name], " +
                            "[calling_plan_id], " +
                            "[virtual_switch_id]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Routing_plan_id") + ", " +
                            _db.CreateSqlParameterName("Name") + ", " +
                            _db.CreateSqlParameterName("Calling_plan_id") + ", " +
                            _db.CreateSqlParameterName("Virtual_switch_id") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Routing_plan_id", value.Routing_plan_id);
            AddParameter(cmd, "Name", value.Name);
            AddParameter(cmd, "Calling_plan_id", value.Calling_plan_id);
            AddParameter(cmd, "Virtual_switch_id", value.Virtual_switch_id);
            cmd.ExecuteNonQuery();
        }
示例#6
0
 /// <summary>
 /// Deletes the specified object from the <c>RoutingPlan</c> table.
 /// </summary>
 /// <param name="value">The <see cref="RoutingPlanRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(RoutingPlanRow value)
 {
     return(DeleteByPrimaryKey(value.Routing_plan_id));
 }