using NHibernate.Mapping.ByCode; using NHibernate.Mapping.ByCode.Conformist; using System; namespace Tanshu.Accounts.Entities { public class PrintLocation { public virtual Guid PrintLocationID { get; set; } public virtual ProductGroup ProductGroup { get; set; } public virtual string Location { get; set; } public virtual string Printer { get; set; } public virtual int Copies { get; set; } public virtual string CutCode { get; set; } public override int GetHashCode() { return Location.GetHashCode() ^ Printer.GetHashCode() ^ Copies.GetHashCode() ^ CutCode.GetHashCode(); } public static bool operator ==(PrintLocation a, PrintLocation b) { if (object.ReferenceEquals(null, a)) return object.ReferenceEquals(null, b); if (!(a is PrintLocation)) return false; if (!(b is PrintLocation)) return false; return a.Location == b.Location && a.Printer == b.Printer && a.Copies == b.Copies && a.CutCode == b.CutCode; } public static bool operator !=(PrintLocation a, PrintLocation b) { return !(a == b); } public override bool Equals(System.Object obj) { if (obj is PrintLocation) return (this == (PrintLocation)obj); else return false; } } public class PrintLocationMap : ClassMapping { public PrintLocationMap() { Table("PrintLocations"); Schema("dbo"); Lazy(true); Id(x => x.PrintLocationID, map => map.Generator(Generators.GuidComb)); Property(x => x.Location); Property(x => x.Printer); Property(x => x.Copies); Property(x => x.CutCode); ManyToOne(x => x.ProductGroup, map => { map.Column("ProductGroupID"); map.Cascade(Cascade.None); }); } } }