- northwind.zip
- 3rd Party
- Castle.DynamicProxy.dll
- HashCodeProvider.dll
- Iesi.Collections.dll
- log4net.dll
- NHibernate.dll
- NHibernate.Nullables2.dll
- Northwind.Controls
- Northwind.Domain
- Northwind.sln
- Northwind.Tests
- Northwind.Web
|
using System;
using System.Collections;
namespace Northwind.Domain.Entities
{
/// <summary>
/// Product object for NHibernate mapped table 'Products'.
/// </summary>
public class Product : EntityBase
{
#region Member Variables
protected int _id;
protected string _productName;
protected string _quantityPerUnit;
protected decimal _unitPrice;
protected short _unitsInStock;
protected short _unitsOnOrder;
protected short _reorderLevel;
protected bool _discontinued;
protected OrderDetail _orderDetail;
protected Category _category = null;
protected Supplier _supplier = null;
protected int categoryID = 0;
protected int supplierID = 0;
#endregion
#region Constructors
public Product() { }
public Product( string productName, string quantityPerUnit, decimal unitPrice, short unitsInStock, short unitsOnOrder, short reorderLevel, bool discontinued, Category category, Supplier supplier )
{
this._productName = productName;
this._quantityPerUnit = quantityPerUnit;
this._unitPrice = unitPrice;
this._unitsInStock = unitsInStock;
this._unitsOnOrder = unitsOnOrder;
this._reorderLevel = reorderLevel;
this._discontinued = discontinued;
this._category = category;
this._supplier = supplier;
}
#endregion
#region Public Properties
public int Id
{
get {return _id;}
set {_id = value;}
}
public string ProductName
{
get { return _productName; }
set
{
if(value != _productName) IsModified = true;
_productName = value;
}
}
public string QuantityPerUnit
{
get { return _quantityPerUnit; }
set
{
if(value != _quantityPerUnit) IsModified = true;
_quantityPerUnit = value;
}
}
public decimal UnitPrice
{
get { return _unitPrice; }
set { _unitPrice = value; }
}
public short UnitsInStock
{
get { return _unitsInStock; }
set { _unitsInStock = value; }
}
public short UnitsOnOrder
{
get { return _unitsOnOrder; }
set { _unitsOnOrder = value; }
}
public short ReorderLevel
{
get { return _reorderLevel; }
set { _reorderLevel = value; }
}
public bool Discontinued
{
get { return _discontinued; }
set { _discontinued = value; }
}
private int CategoryID
{
get{return categoryID;}
set{ categoryID = value;}
}
private int SupplierID
{
get { return supplierID; }
set { supplierID = value; }
}
public Category Category
{
get
{
if(_category==null)
{
Repository r = new Repository();
r.Open();
Category category =(Category) r.Get(typeof (Category), categoryID);
_category = category;
}
return _category;
}
set {
_category = value;
categoryID = value.Id;
}
}
public Supplier Supplier
{
get
{
if (_supplier == null)
{
Repository r = new Repository();
r.Open();
Supplier supplier = (Supplier)r.Get(typeof(Supplier), supplierID);
_supplier = supplier;
}
return _supplier;
}
set {
_supplier = value;
supplierID = value.Id;
}
}
public OrderDetail OrderDetail
{
get { return _orderDetail; }
set { _orderDetail = value; }
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Independent contract developer for .NET data-oriented systems.
not much to say about myself but feel free to contact me for any inquiries and comments!