/// <summary>
        /// Updates a record in the <c>tblVendor</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblVendorRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(tblVendorRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblVendor_Update", true);

            AddParameter(cmd, "Vendor_Name", value.Vendor_Name);
            AddParameter(cmd, "Address", value.Address);
            AddParameter(cmd, "Contact_No",
                         value.IsContact_NoNull ? DBNull.Value : (object)value.Contact_No);
            AddParameter(cmd, "Email", value.Email);
            AddParameter(cmd, "Country",
                         value.IsCountryNull ? DBNull.Value : (object)value.Country);
            AddParameter(cmd, "Vendor_Type_Id", value.Vendor_Type_Id);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "Currency_Id",
                         value.IsCurrency_IdNull ? DBNull.Value : (object)value.Currency_Id);
            AddParameter(cmd, "GL_Act_Id",
                         value.IsGL_Act_IdNull ? DBNull.Value : (object)value.GL_Act_Id);
            AddParameter(cmd, "Created_By",
                         value.IsCreated_ByNull ? DBNull.Value : (object)value.Created_By);
            AddParameter(cmd, "Created_Time",
                         value.IsCreated_TimeNull ? DBNull.Value : (object)value.Created_Time);
            AddParameter(cmd, "Updated_By",
                         value.IsUpdated_ByNull ? DBNull.Value : (object)value.Updated_By);
            AddParameter(cmd, "Updated_Time",
                         value.IsUpdated_TimeNull ? DBNull.Value : (object)value.Updated_Time);
            AddParameter(cmd, "Vendor_Id", value.Vendor_Id);
            return(0 != cmd.ExecuteNonQuery());
        }
        /// <summary>
        /// Adds a new record into the <c>tblVendor</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblVendorRow"/> object to be inserted.</param>
        public virtual void Insert(tblVendorRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblVendor_Insert", true);

            AddParameter(cmd, "Vendor_Name", value.Vendor_Name);
            AddParameter(cmd, "Address", value.Address);
            AddParameter(cmd, "Contact_No",
                         value.IsContact_NoNull ? DBNull.Value : (object)value.Contact_No);
            AddParameter(cmd, "Email", value.Email);
            AddParameter(cmd, "Country",
                         value.IsCountryNull ? DBNull.Value : (object)value.Country);
            AddParameter(cmd, "Vendor_Type_Id", value.Vendor_Type_Id);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "Currency_Id",
                         value.IsCurrency_IdNull ? DBNull.Value : (object)value.Currency_Id);
            AddParameter(cmd, "GL_Act_Id",
                         value.IsGL_Act_IdNull ? DBNull.Value : (object)value.GL_Act_Id);
            AddParameter(cmd, "Created_By",
                         value.IsCreated_ByNull ? DBNull.Value : (object)value.Created_By);
            AddParameter(cmd, "Created_Time",
                         value.IsCreated_TimeNull ? DBNull.Value : (object)value.Created_Time);
            AddParameter(cmd, "Updated_By",
                         value.IsUpdated_ByNull ? DBNull.Value : (object)value.Updated_By);
            AddParameter(cmd, "Updated_Time",
                         value.IsUpdated_TimeNull ? DBNull.Value : (object)value.Updated_Time);
            value.Vendor_Id = Convert.ToInt32(cmd.ExecuteScalar());
        }
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="tblVendorRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="tblVendorRow"/> object.</returns>
        protected virtual tblVendorRow MapRow(DataRow row)
        {
            tblVendorRow mappedObject = new tblVendorRow();
            DataTable    dataTable    = row.Table;
            DataColumn   dataColumn;

            // Column "Vendor_Id"
            dataColumn = dataTable.Columns["Vendor_Id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Vendor_Id = (int)row[dataColumn];
            }
            // Column "Vendor_Name"
            dataColumn = dataTable.Columns["Vendor_Name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Vendor_Name = (string)row[dataColumn];
            }
            // Column "Address"
            dataColumn = dataTable.Columns["Address"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Address = (string)row[dataColumn];
            }
            // Column "Contact_No"
            dataColumn = dataTable.Columns["Contact_No"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Contact_No = (int)row[dataColumn];
            }
            // Column "Email"
            dataColumn = dataTable.Columns["Email"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Email = (string)row[dataColumn];
            }
            // Column "Country"
            dataColumn = dataTable.Columns["Country"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Country = (int)row[dataColumn];
            }
            // Column "Vendor_Type_Id"
            dataColumn = dataTable.Columns["Vendor_Type_Id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Vendor_Type_Id = (int)row[dataColumn];
            }
            // Column "Status"
            dataColumn = dataTable.Columns["Status"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Status = (bool)row[dataColumn];
            }
            // Column "Currency_Id"
            dataColumn = dataTable.Columns["Currency_Id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Currency_Id = (int)row[dataColumn];
            }
            // Column "GL_Act_Id"
            dataColumn = dataTable.Columns["GL_Act_Id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.GL_Act_Id = (int)row[dataColumn];
            }
            // Column "Created_By"
            dataColumn = dataTable.Columns["Created_By"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Created_By = (int)row[dataColumn];
            }
            // Column "Created_Time"
            dataColumn = dataTable.Columns["Created_Time"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Created_Time = (System.DateTime)row[dataColumn];
            }
            // Column "Updated_By"
            dataColumn = dataTable.Columns["Updated_By"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Updated_By = (int)row[dataColumn];
            }
            // Column "Updated_Time"
            dataColumn = dataTable.Columns["Updated_Time"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Updated_Time = (System.DateTime)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="tblVendorRow"/> objects.</returns>
        protected virtual tblVendorRow[] 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_IdColumnIndex      = reader.GetOrdinal("Vendor_Id");
            int vendor_NameColumnIndex    = reader.GetOrdinal("Vendor_Name");
            int addressColumnIndex        = reader.GetOrdinal("Address");
            int contact_NoColumnIndex     = reader.GetOrdinal("Contact_No");
            int emailColumnIndex          = reader.GetOrdinal("Email");
            int countryColumnIndex        = reader.GetOrdinal("Country");
            int vendor_Type_IdColumnIndex = reader.GetOrdinal("Vendor_Type_Id");
            int statusColumnIndex         = reader.GetOrdinal("Status");
            int currency_IdColumnIndex    = reader.GetOrdinal("Currency_Id");
            int gL_Act_IdColumnIndex      = reader.GetOrdinal("GL_Act_Id");
            int created_ByColumnIndex     = reader.GetOrdinal("Created_By");
            int created_TimeColumnIndex   = reader.GetOrdinal("Created_Time");
            int updated_ByColumnIndex     = reader.GetOrdinal("Updated_By");
            int updated_TimeColumnIndex   = reader.GetOrdinal("Updated_Time");

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

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

                    record.Vendor_Id   = Convert.ToInt32(reader.GetValue(vendor_IdColumnIndex));
                    record.Vendor_Name = Convert.ToString(reader.GetValue(vendor_NameColumnIndex));
                    if (!reader.IsDBNull(addressColumnIndex))
                    {
                        record.Address = Convert.ToString(reader.GetValue(addressColumnIndex));
                    }
                    if (!reader.IsDBNull(contact_NoColumnIndex))
                    {
                        record.Contact_No = Convert.ToInt32(reader.GetValue(contact_NoColumnIndex));
                    }
                    if (!reader.IsDBNull(emailColumnIndex))
                    {
                        record.Email = Convert.ToString(reader.GetValue(emailColumnIndex));
                    }
                    if (!reader.IsDBNull(countryColumnIndex))
                    {
                        record.Country = Convert.ToInt32(reader.GetValue(countryColumnIndex));
                    }
                    record.Vendor_Type_Id = Convert.ToInt32(reader.GetValue(vendor_Type_IdColumnIndex));
                    record.Status         = Convert.ToBoolean(reader.GetValue(statusColumnIndex));
                    if (!reader.IsDBNull(currency_IdColumnIndex))
                    {
                        record.Currency_Id = Convert.ToInt32(reader.GetValue(currency_IdColumnIndex));
                    }
                    if (!reader.IsDBNull(gL_Act_IdColumnIndex))
                    {
                        record.GL_Act_Id = Convert.ToInt32(reader.GetValue(gL_Act_IdColumnIndex));
                    }
                    if (!reader.IsDBNull(created_ByColumnIndex))
                    {
                        record.Created_By = Convert.ToInt32(reader.GetValue(created_ByColumnIndex));
                    }
                    if (!reader.IsDBNull(created_TimeColumnIndex))
                    {
                        record.Created_Time = Convert.ToDateTime(reader.GetValue(created_TimeColumnIndex));
                    }
                    if (!reader.IsDBNull(updated_ByColumnIndex))
                    {
                        record.Updated_By = Convert.ToInt32(reader.GetValue(updated_ByColumnIndex));
                    }
                    if (!reader.IsDBNull(updated_TimeColumnIndex))
                    {
                        record.Updated_Time = Convert.ToDateTime(reader.GetValue(updated_TimeColumnIndex));
                    }

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

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