69617949bd
Important! : This version will not work. It is pre-alpha and saved in case of catastrophic failure Refactor: Remove dependency on Fluent Nhibernate. Refactor: All Primary keys are now Guids. Refactor: Class Mappings changed from AutoMap to Explicit Mappings. Breakage: All Cascading is now disabled and entities must be explicitly saved/updated/deleted Breakage: Auto Commiting is now off and "SaveChanges()" needs to be called on all BIs. Refactor: Changed the pattern where all relevant db code for an operation is basically in the same function. Chore: Removed Advance and Payments options.
60 lines
2.6 KiB
C#
60 lines
2.6 KiB
C#
using Tanshu.Accounts.Contracts;
|
|
using NHibernate.Mapping.ByCode.Conformist;
|
|
using NHibernate.Mapping.ByCode;
|
|
using System.Collections.Generic;
|
|
using System;
|
|
|
|
namespace Tanshu.Accounts.Entities
|
|
{
|
|
public class Product
|
|
{
|
|
public virtual Guid ProductID { get; set; }
|
|
public virtual int Code { get; set; }
|
|
public virtual string Name { get; set; }
|
|
public virtual string Units { get; set; }
|
|
public virtual ProductGroup ProductGroup { get; set; }
|
|
public virtual Tax Vat { get; set; }
|
|
public virtual Tax ServiceTax { get; set; }
|
|
public virtual decimal ServiceCharge { get; set; }
|
|
public virtual bool IsScTaxable { get; set; }
|
|
public virtual decimal Price { get; set; }
|
|
public virtual decimal FullPrice { get; set; }
|
|
public virtual bool Discontinued { get; set; }
|
|
public virtual int SortOrder { get; set; }
|
|
[NotNull]
|
|
public virtual int BaseCode { get; set; }
|
|
[NotNull]
|
|
public virtual decimal Quantity { get; set; }
|
|
public virtual IList<Inventory> Inventories { get; set; }
|
|
|
|
}
|
|
public class ProductMap : ClassMapping<Product>
|
|
{
|
|
|
|
public ProductMap()
|
|
{
|
|
Table("Products");
|
|
Schema("dbo");
|
|
Lazy(true);
|
|
Id(x => x.ProductID, map => map.Generator(Generators.GuidComb));
|
|
Property(x => x.Code);
|
|
Property(x => x.Name, map => { map.NotNullable(true); map.UniqueKey("UQ_NameUnits"); });
|
|
Property(x => x.Units, map => { map.NotNullable(true); map.UniqueKey("UQ_NameUnits"); });
|
|
Property(x => x.ServiceCharge, map => map.NotNullable(true));
|
|
Property(x => x.IsScTaxable, map => map.NotNullable(true));
|
|
Property(x => x.Price, map => map.NotNullable(true));
|
|
Property(x => x.FullPrice, map => map.NotNullable(true));
|
|
Property(x => x.Discontinued, map => map.NotNullable(true));
|
|
Property(x => x.SortOrder, map => map.NotNullable(true));
|
|
Property(x => x.BaseCode, map => map.NotNullable(true));
|
|
Property(x => x.Quantity, map => map.NotNullable(true));
|
|
|
|
ManyToOne(x => x.ProductGroup, map => { map.Column("ProductGroupID"); map.Cascade(Cascade.None); });
|
|
ManyToOne(x => x.ServiceTax, map => { map.Column("ServiceTaxID"); map.Cascade(Cascade.None); });
|
|
ManyToOne(x => x.Vat, map => { map.Column("VatID"); map.Cascade(Cascade.None); });
|
|
Bag(x => x.Inventories, colmap => { colmap.Key(x => x.Column("ProductID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
|
|
}
|
|
}
|
|
|
|
}
|