Example #1
0
        /// <summary>
        /// Updates a record in the <c>IPAddress</c> table.
        /// </summary>
        /// <param name="value">The <see cref="IPAddressRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(IPAddressRow value)
        {
            string sqlStr = "UPDATE [dbo].[IPAddress] SET " +
                            "[end_point_id]=" + _db.CreateSqlParameterName("End_point_id") +
                            " WHERE " +
                            "[IP_address]=" + _db.CreateSqlParameterName("IP_address");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "End_point_id", value.End_point_id);
            AddParameter(cmd, "IP_address", value.IP_address);
            return(0 != cmd.ExecuteNonQuery());
        }
Example #2
0
        /// <summary>
        /// Adds a new record into the <c>IPAddress</c> table.
        /// </summary>
        /// <param name="value">The <see cref="IPAddressRow"/> object to be inserted.</param>
        public virtual void Insert(IPAddressRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[IPAddress] (" +
                            "[IP_address], " +
                            "[end_point_id]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("IP_address") + ", " +
                            _db.CreateSqlParameterName("End_point_id") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "IP_address", value.IP_address);
            AddParameter(cmd, "End_point_id", value.End_point_id);
            cmd.ExecuteNonQuery();
        }
Example #3
0
 static void addIPAddressCollection(Rbr_Db pDb, EndPointRow pEndPointRow)
 {
     if (pEndPointRow == null || pEndPointRow.Ip_address_range == null)
     {
         throw new ApplicationException("At least one IPAddress should be passed");
     }
     foreach (int _ip in pEndPointRow.IPAddressRange.IPAddressInt32List)
     {
         var _ipAddressRow = new IPAddressRow();
         _ipAddressRow.IP_address   = _ip;
         _ipAddressRow.End_point_id = pEndPointRow.End_point_id;
         pDb.IPAddressCollection.Insert(_ipAddressRow);
     }
 }
Example #4
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="IPAddressRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="IPAddressRow"/> object.</returns>
        protected virtual IPAddressRow MapRow(DataRow row)
        {
            IPAddressRow mappedObject = new IPAddressRow();
            DataTable    dataTable    = row.Table;
            DataColumn   dataColumn;

            // Column "IP_address"
            dataColumn = dataTable.Columns["IP_address"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.IP_address = (int)row[dataColumn];
            }
            // Column "End_point_id"
            dataColumn = dataTable.Columns["End_point_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.End_point_id = (short)row[dataColumn];
            }
            return(mappedObject);
        }
Example #5
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="IPAddressRow"/> objects.</returns>
        protected virtual IPAddressRow[] 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 iP_addressColumnIndex   = reader.GetOrdinal("IP_address");
            int end_point_idColumnIndex = reader.GetOrdinal("end_point_id");

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

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

                    record.IP_address   = Convert.ToInt32(reader.GetValue(iP_addressColumnIndex));
                    record.End_point_id = Convert.ToInt16(reader.GetValue(end_point_idColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((IPAddressRow[])(recordList.ToArray(typeof(IPAddressRow))));
        }
Example #6
0
 /// <summary>
 /// Deletes the specified object from the <c>IPAddress</c> table.
 /// </summary>
 /// <param name="value">The <see cref="IPAddressRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(IPAddressRow value)
 {
     return(DeleteByPrimaryKey(value.IP_address));
 }