// <fileinfo name="ProductsbyCategoryRow_Base.cs">
//      <copyright>
//          All rights reserved.
//      </copyright>
//      <remarks>
//          Do not change this source code manually. Changes to this file may 
//          cause incorrect behavior and will be lost if the code is regenerated.
//      </remarks>
//      <generator rewritefile="True" infourl="http://www.SharpPower.com">RapTier</generator>
// </fileinfo>

using System;

namespace MyCompany.MyProject.Db
{
    /// <summary>
    /// The base class for <see cref="ProductsbyCategoryRow"/> that 
    /// represents a record in the <c>Products by Category</c> view.
    /// </summary>
    /// <remarks>
    /// Do not change this source code manually. Update the <see cref="ProductsbyCategoryRow"/>
    /// class if you need to add or change some functionality.
    /// </remarks>
    public abstract class ProductsbyCategoryRow_Base
    {
        private string _categoryName;
        private string _productName;
        private string _quantityPerUnit;
        private short _unitsInStock;
        private bool _unitsInStockNull = true;
        private bool _discontinued;

        /// <summary>
        /// Initializes a new instance of the <see cref="ProductsbyCategoryRow_Base"/> class.
        /// </summary>
        public ProductsbyCategoryRow_Base()
        {
            // EMPTY
        }

        /// <summary>
        /// Gets or sets the <c>CategoryName</c> column value.
        /// </summary>
        /// <value>The <c>CategoryName</c> column value.</value>
        public string CategoryName
        {
            get { return _categoryName; }
            set { _categoryName = value; }
        }

        /// <summary>
        /// Gets or sets the <c>ProductName</c> column value.
        /// </summary>
        /// <value>The <c>ProductName</c> column value.</value>
        public string ProductName
        {
            get { return _productName; }
            set { _productName = value; }
        }

        /// <summary>
        /// Gets or sets the <c>QuantityPerUnit</c> column value.
        /// This column is nullable.
        /// </summary>
        /// <value>The <c>QuantityPerUnit</c> column value.</value>
        public string QuantityPerUnit
        {
            get { return _quantityPerUnit; }
            set { _quantityPerUnit = value; }
        }

        /// <summary>
        /// Gets or sets the <c>UnitsInStock</c> column value.
        /// This column is nullable.
        /// </summary>
        /// <value>The <c>UnitsInStock</c> column value.</value>
        public short UnitsInStock
        {
            get
            {
                if(IsUnitsInStockNull)
                    throw new InvalidOperationException("Cannot get value because it is DBNull.");
                return _unitsInStock;
            }
            set
            {
                _unitsInStockNull = false;
                _unitsInStock = value;
            }
        }

        /// <summary>
        /// Indicates whether the <see cref="UnitsInStock"/>
        /// property value is null.
        /// </summary>
        /// <value>true if the property value is null, otherwise false.</value>
        public bool IsUnitsInStockNull
        {
            get { return _unitsInStockNull; }
            set { _unitsInStockNull = value; }
        }

        /// <summary>
        /// Gets or sets the <c>Discontinued</c> column value.
        /// </summary>
        /// <value>The <c>Discontinued</c> column value.</value>
        public bool Discontinued
        {
            get { return _discontinued; }
            set { _discontinued = value; }
        }

        /// <summary>
        /// Returns the string representation of this instance.
        /// </summary>
        /// <returns>The string representation of this instance.</returns>
        public override string ToString()
        {
            System.Text.StringBuilder dynStr = new System.Text.StringBuilder(GetType().Name);
            dynStr.Append(':');
            dynStr.Append("  CategoryName=");
            dynStr.Append(CategoryName);
            dynStr.Append("  ProductName=");
            dynStr.Append(ProductName);
            dynStr.Append("  QuantityPerUnit=");
            dynStr.Append(QuantityPerUnit);
            dynStr.Append("  UnitsInStock=");
            dynStr.Append(IsUnitsInStockNull ? (object)"<NULL>" : UnitsInStock);
            dynStr.Append("  Discontinued=");
            dynStr.Append(Discontinued);
            return dynStr.ToString();
        }
    } // End of ProductsbyCategoryRow_Base class
} // End of namespace