/// <summary>
        /// Adds a new record into the <c>tblVendor_Type</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblVendor_TypeRow"/> object to be inserted.</param>
        public virtual void Insert(tblVendor_TypeRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblVendor_Type_Insert", true);

            AddParameter(cmd, "Type_Name", value.Type_Name);
            value.Vendor_Type_Id = Convert.ToInt32(cmd.ExecuteScalar());
        }
        /// <summary>
        /// Updates a record in the <c>tblVendor_Type</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblVendor_TypeRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(tblVendor_TypeRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblVendor_Type_Update", true);

            AddParameter(cmd, "Type_Name", value.Type_Name);
            AddParameter(cmd, "Vendor_Type_Id", value.Vendor_Type_Id);
            return(0 != cmd.ExecuteNonQuery());
        }
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="tblVendor_TypeRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="tblVendor_TypeRow"/> object.</returns>
        protected virtual tblVendor_TypeRow MapRow(DataRow row)
        {
            tblVendor_TypeRow mappedObject = new tblVendor_TypeRow();
            DataTable         dataTable    = row.Table;
            DataColumn        dataColumn;

            // Column "Vendor_Type_Id"
            dataColumn = dataTable.Columns["Vendor_Type_Id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Vendor_Type_Id = (int)row[dataColumn];
            }
            // Column "Type_Name"
            dataColumn = dataTable.Columns["Type_Name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Type_Name = (string)row[dataColumn];
            }
            return(mappedObject);
        }
        /// <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="tblVendor_TypeRow"/> objects.</returns>
        protected virtual tblVendor_TypeRow[] 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 vendor_Type_IdColumnIndex = reader.GetOrdinal("Vendor_Type_Id");
            int type_NameColumnIndex      = reader.GetOrdinal("Type_Name");

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

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

                    record.Vendor_Type_Id = Convert.ToInt32(reader.GetValue(vendor_Type_IdColumnIndex));
                    record.Type_Name      = Convert.ToString(reader.GetValue(type_NameColumnIndex));

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

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