/// <summary>
 /// Deletes the specified object from the <c>B2CProductData</c> table.
 /// </summary>
 /// <param name="value">The <see cref="B2CProductDataRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(B2CProductDataRow value)
 {
     return DeleteByPrimaryKey(value.PkID);
 }
 /// <summary>
 /// Converts <see cref="System.Data.DataRow"/> to <see cref="B2CProductDataRow"/>.
 /// </summary>
 /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
 /// <returns>A reference to the <see cref="B2CProductDataRow"/> object.</returns>
 protected virtual B2CProductDataRow MapRow(DataRow row)
 {
     B2CProductDataRow mappedObject = new B2CProductDataRow();
     DataTable dataTable = row.Table;
     DataColumn dataColumn;
     // Column "PkID"
     dataColumn = dataTable.Columns["PkID"];
     if(!row.IsNull(dataColumn))
         mappedObject.PkID = (int)row[dataColumn];
     // Column "StyleNumber"
     dataColumn = dataTable.Columns["StyleNumber"];
     if(!row.IsNull(dataColumn))
         mappedObject.StyleNumber = (string)row[dataColumn];
     // Column "ProductName"
     dataColumn = dataTable.Columns["ProductName"];
     if(!row.IsNull(dataColumn))
         mappedObject.ProductName = (string)row[dataColumn];
     // Column "BrandName"
     dataColumn = dataTable.Columns["BrandName"];
     if(!row.IsNull(dataColumn))
         mappedObject.BrandName = (string)row[dataColumn];
     // Column "ProductDescEn"
     dataColumn = dataTable.Columns["ProductDescEn"];
     if(!row.IsNull(dataColumn))
         mappedObject.ProductDescEn = (string)row[dataColumn];
     // Column "ProductDescFr"
     dataColumn = dataTable.Columns["ProductDescFr"];
     if(!row.IsNull(dataColumn))
         mappedObject.ProductDescFr = (string)row[dataColumn];
     return mappedObject;
 }
 /// <summary>
 /// Updates a record in the <c>B2CProductData</c> table.
 /// </summary>
 /// <param name="value">The <see cref="B2CProductDataRow"/>
 /// object used to update the table record.</param>
 /// <returns>true if the record was updated; otherwise, false.</returns>
 public virtual bool Update(B2CProductDataRow value)
 {
     string sqlStr = "UPDATE [dbo].[B2CProductData] SET " +
         "[StyleNumber]=" + _db.CreateSqlParameterName("StyleNumber") + ", " +
         "[ProductName]=" + _db.CreateSqlParameterName("ProductName") + ", " +
         "[BrandName]=" + _db.CreateSqlParameterName("BrandName") + ", " +
         "[ProductDescEn]=" + _db.CreateSqlParameterName("ProductDescEn") + ", " +
         "[ProductDescFr]=" + _db.CreateSqlParameterName("ProductDescFr") +
         " WHERE " +
         "[PkID]=" + _db.CreateSqlParameterName("PkID");
     IDbCommand cmd = _db.CreateCommand(sqlStr);
     AddParameter(cmd, "StyleNumber", value.StyleNumber);
     AddParameter(cmd, "ProductName", value.ProductName);
     AddParameter(cmd, "BrandName", value.BrandName);
     AddParameter(cmd, "ProductDescEn", value.ProductDescEn);
     AddParameter(cmd, "ProductDescFr", value.ProductDescFr);
     AddParameter(cmd, "PkID", value.PkID);
     return 0 != cmd.ExecuteNonQuery();
 }
        /// <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="B2CProductDataRow"/> objects.</returns>
        protected virtual B2CProductDataRow[] 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 pkIDColumnIndex = reader.GetOrdinal("PkID");
            int styleNumberColumnIndex = reader.GetOrdinal("StyleNumber");
            int productNameColumnIndex = reader.GetOrdinal("ProductName");
            int brandNameColumnIndex = reader.GetOrdinal("BrandName");
            int productDescEnColumnIndex = reader.GetOrdinal("ProductDescEn");
            int productDescFrColumnIndex = reader.GetOrdinal("ProductDescFr");

            System.Collections.ArrayList recordList = new System.Collections.ArrayList();
            int ri = -startIndex;
            while(reader.Read())
            {
                ri++;
                if(ri > 0 && ri <= length)
                {
                    B2CProductDataRow record = new B2CProductDataRow();
                    recordList.Add(record);

                    record.PkID = Convert.ToInt32(reader.GetValue(pkIDColumnIndex));
                    record.StyleNumber = Convert.ToString(reader.GetValue(styleNumberColumnIndex));
                    if(!reader.IsDBNull(productNameColumnIndex))
                        record.ProductName = Convert.ToString(reader.GetValue(productNameColumnIndex));
                    if(!reader.IsDBNull(brandNameColumnIndex))
                        record.BrandName = Convert.ToString(reader.GetValue(brandNameColumnIndex));
                    if(!reader.IsDBNull(productDescEnColumnIndex))
                        record.ProductDescEn = Convert.ToString(reader.GetValue(productDescEnColumnIndex));
                    if(!reader.IsDBNull(productDescFrColumnIndex))
                        record.ProductDescFr = Convert.ToString(reader.GetValue(productDescFrColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return (B2CProductDataRow[])(recordList.ToArray(typeof(B2CProductDataRow)));
        }
 /// <summary>
 /// Adds a new record into the <c>B2CProductData</c> table.
 /// </summary>
 /// <param name="value">The <see cref="B2CProductDataRow"/> object to be inserted.</param>
 public virtual void Insert(B2CProductDataRow value)
 {
     string sqlStr = "INSERT INTO [dbo].[B2CProductData] (" +
         "[StyleNumber], " +
         "[ProductName], " +
         "[BrandName], " +
         "[ProductDescEn], " +
         "[ProductDescFr]" +
         ") VALUES (" +
         _db.CreateSqlParameterName("StyleNumber") + ", " +
         _db.CreateSqlParameterName("ProductName") + ", " +
         _db.CreateSqlParameterName("BrandName") + ", " +
         _db.CreateSqlParameterName("ProductDescEn") + ", " +
         _db.CreateSqlParameterName("ProductDescFr") + ");SELECT @@IDENTITY";
     IDbCommand cmd = _db.CreateCommand(sqlStr);
     AddParameter(cmd, "StyleNumber", value.StyleNumber);
     AddParameter(cmd, "ProductName", value.ProductName);
     AddParameter(cmd, "BrandName", value.BrandName);
     AddParameter(cmd, "ProductDescEn", value.ProductDescEn);
     AddParameter(cmd, "ProductDescFr", value.ProductDescFr);
     value.PkID = Convert.ToInt32(cmd.ExecuteScalar());
 }