2011-02-18 16:54:48 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
using Tanshu.Accounts.Entities.Auth;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Tanshu.Accounts.Contracts;
|
2014-10-12 09:41:45 +00:00
|
|
|
|
using NHibernate.Mapping.ByCode.Conformist;
|
|
|
|
|
using NHibernate.Mapping.ByCode;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.Entities
|
|
|
|
|
{
|
|
|
|
|
public class Kot
|
|
|
|
|
{
|
2014-10-12 09:41:45 +00:00
|
|
|
|
public Kot()
|
|
|
|
|
{
|
|
|
|
|
Inventories = new List<Inventory>();
|
|
|
|
|
Printed = false;
|
|
|
|
|
}
|
|
|
|
|
public virtual Guid KotID { get; set; }
|
2011-02-18 16:54:48 +00:00
|
|
|
|
public virtual Voucher Voucher { get; set; }
|
2014-11-06 10:39:11 +00:00
|
|
|
|
protected int _code;
|
|
|
|
|
public virtual int Code { get { return _code; } }
|
2014-10-16 11:11:55 +00:00
|
|
|
|
public virtual FoodTable Table { get; set; }
|
2011-02-18 16:54:48 +00:00
|
|
|
|
public virtual bool Printed { get; set; }
|
|
|
|
|
public virtual DateTime Date { get; set; }
|
|
|
|
|
public virtual User User { get; set; }
|
|
|
|
|
public virtual IList<Inventory> Inventories { get; set; }
|
2014-10-12 09:41:45 +00:00
|
|
|
|
}
|
|
|
|
|
public class KotMap : ClassMapping<Kot>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public KotMap()
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
2014-10-12 09:41:45 +00:00
|
|
|
|
Table("Kots");
|
|
|
|
|
Schema("dbo");
|
|
|
|
|
Lazy(true);
|
2014-11-02 08:03:31 +00:00
|
|
|
|
SqlInsert(@"exec KotInsert ?,?,?,?,?");
|
2014-10-12 09:41:45 +00:00
|
|
|
|
Id(x => x.KotID, map => map.Generator(Generators.GuidComb));
|
2014-11-02 08:03:31 +00:00
|
|
|
|
Property(x => x.Code, map =>
|
|
|
|
|
{
|
|
|
|
|
map.NotNullable(true);
|
|
|
|
|
map.Unique(true);
|
|
|
|
|
map.Generated(PropertyGeneration.Insert);
|
2014-11-06 10:39:11 +00:00
|
|
|
|
map.Access(Accessor.NoSetter);
|
2014-11-02 08:03:31 +00:00
|
|
|
|
});
|
2014-10-12 09:41:45 +00:00
|
|
|
|
Property(x => x.Printed, map => map.NotNullable(true));
|
2014-11-02 08:03:31 +00:00
|
|
|
|
Property(x => x.Date, map =>
|
|
|
|
|
{
|
|
|
|
|
map.NotNullable(true);
|
|
|
|
|
map.Generated(PropertyGeneration.Insert);
|
|
|
|
|
});
|
2014-10-12 09:41:45 +00:00
|
|
|
|
ManyToOne(x => x.Voucher, map =>
|
|
|
|
|
{
|
|
|
|
|
map.Column("VoucherID");
|
|
|
|
|
map.NotNullable(true);
|
|
|
|
|
map.Cascade(Cascade.None);
|
|
|
|
|
});
|
|
|
|
|
|
2014-10-16 11:11:55 +00:00
|
|
|
|
ManyToOne(x => x.Table, map =>
|
|
|
|
|
{
|
|
|
|
|
map.Column("TableID");
|
|
|
|
|
map.NotNullable(true);
|
|
|
|
|
map.Cascade(Cascade.None);
|
|
|
|
|
});
|
|
|
|
|
|
2014-10-12 09:41:45 +00:00
|
|
|
|
ManyToOne(x => x.User, map =>
|
|
|
|
|
{
|
|
|
|
|
map.Column("UserID");
|
|
|
|
|
map.NotNullable(true);
|
|
|
|
|
map.Cascade(Cascade.None);
|
|
|
|
|
});
|
|
|
|
|
|
2014-11-10 11:06:49 +00:00
|
|
|
|
Bag(x => x.Inventories, colmap =>
|
|
|
|
|
{
|
|
|
|
|
colmap.Key(x => x.Column("KotID"));
|
|
|
|
|
colmap.Inverse(true);
|
|
|
|
|
colmap.OrderBy(x => x.SortOrder);
|
|
|
|
|
}, map => { map.OneToMany(); });
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|