narsil/Tanshu.Accounts.Contracts/Data Contracts/CustomerBO.cs

34 lines
1.2 KiB
C#

using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;
using System;
using System.Collections.Generic;
namespace Tanshu.Accounts.Entities
{
public class Customer
{
public virtual Guid CustomerID { get; set; }
public virtual string Name { get; set; }
public virtual string Address { get; set; }
public virtual bool Important { get; set; }
public virtual string Phone { get; set; }
public virtual string Remarks { get; set; }
public virtual IList<Voucher> Vouchers { get; set; }
}
public class CustomerMap : ClassMapping<Customer>
{
public CustomerMap()
{
Table("Customers");
Schema("dbo");
Lazy(true);
Id(x => x.CustomerID, map => map.Generator(Generators.GuidComb));
Property(x => x.Name, map => { map.NotNullable(true); map.Unique(true); });
Property(x => x.Address);
Property(x => x.Important);
Property(x => x.Phone);
Property(x => x.Remarks);
Bag(x => x.Vouchers, colmap => { colmap.Key(x => x.Column("CustomerID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
}
}
}