示例#1
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="PrefixInTypeRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="PrefixInTypeRow"/> object.</returns>
        protected virtual PrefixInTypeRow MapRow(DataRow row)
        {
            PrefixInTypeRow mappedObject = new PrefixInTypeRow();
            DataTable       dataTable    = row.Table;
            DataColumn      dataColumn;

            // Column "Prefix_in_type_id"
            dataColumn = dataTable.Columns["Prefix_in_type_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Prefix_in_type_id = (short)row[dataColumn];
            }
            // Column "Description"
            dataColumn = dataTable.Columns["Description"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Description = (string)row[dataColumn];
            }
            // Column "Length"
            dataColumn = dataTable.Columns["Length"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Length = (byte)row[dataColumn];
            }
            // Column "Delimiter"
            dataColumn = dataTable.Columns["Delimiter"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Delimiter = (byte)row[dataColumn];
            }
            return(mappedObject);
        }
示例#2
0
        /// <summary>
        /// Updates a record in the <c>PrefixInType</c> table.
        /// </summary>
        /// <param name="value">The <see cref="PrefixInTypeRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(PrefixInTypeRow value)
        {
            string sqlStr = "UPDATE [dbo].[PrefixInType] SET " +
                            "[description]=" + _db.CreateSqlParameterName("Description") + ", " +
                            "[length]=" + _db.CreateSqlParameterName("Length") + ", " +
                            "[delimiter]=" + _db.CreateSqlParameterName("Delimiter") +
                            " WHERE " +
                            "[prefix_in_type_id]=" + _db.CreateSqlParameterName("Prefix_in_type_id");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Description", value.Description);
            AddParameter(cmd, "Length", value.Length);
            AddParameter(cmd, "Delimiter", value.Delimiter);
            AddParameter(cmd, "Prefix_in_type_id", value.Prefix_in_type_id);
            return(0 != cmd.ExecuteNonQuery());
        }
示例#3
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="PrefixInTypeRow"/> objects.</returns>
        protected virtual PrefixInTypeRow[] 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 prefix_in_type_idColumnIndex = reader.GetOrdinal("prefix_in_type_id");
            int descriptionColumnIndex       = reader.GetOrdinal("description");
            int lengthColumnIndex            = reader.GetOrdinal("length");
            int delimiterColumnIndex         = reader.GetOrdinal("delimiter");

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

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

                    record.Prefix_in_type_id = Convert.ToInt16(reader.GetValue(prefix_in_type_idColumnIndex));
                    record.Description       = Convert.ToString(reader.GetValue(descriptionColumnIndex));
                    record.Length            = Convert.ToByte(reader.GetValue(lengthColumnIndex));
                    record.Delimiter         = Convert.ToByte(reader.GetValue(delimiterColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((PrefixInTypeRow[])(recordList.ToArray(typeof(PrefixInTypeRow))));
        }
示例#4
0
        /// <summary>
        /// Adds a new record into the <c>PrefixInType</c> table.
        /// </summary>
        /// <param name="value">The <see cref="PrefixInTypeRow"/> object to be inserted.</param>
        public virtual void Insert(PrefixInTypeRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[PrefixInType] (" +
                            "[prefix_in_type_id], " +
                            "[description], " +
                            "[length], " +
                            "[delimiter]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Prefix_in_type_id") + ", " +
                            _db.CreateSqlParameterName("Description") + ", " +
                            _db.CreateSqlParameterName("Length") + ", " +
                            _db.CreateSqlParameterName("Delimiter") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Prefix_in_type_id", value.Prefix_in_type_id);
            AddParameter(cmd, "Description", value.Description);
            AddParameter(cmd, "Length", value.Length);
            AddParameter(cmd, "Delimiter", value.Delimiter);
            cmd.ExecuteNonQuery();
        }
示例#5
0
 /// <summary>
 /// Deletes the specified object from the <c>PrefixInType</c> table.
 /// </summary>
 /// <param name="value">The <see cref="PrefixInTypeRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(PrefixInTypeRow value)
 {
     return(DeleteByPrimaryKey(value.Prefix_in_type_id));
 }