日期:2014-05-20 浏览次数:20485 次
[Serializable] public class A { /// <summary> ///唯一标识 /// </summary> public virtual string ID { get; set; } /// <summary> ///姓名 /// </summary> public virtual string Name { get; set; } } [Serializable] public class B { /// <summary> ///唯一标识 /// </summary> public virtual string ID { get; set; } /// <summary> ///姓名 /// </summary> public virtual DateTime LastTime { get; set; } /// <summary> ///姓名 /// </summary> public virtual string Name { get; set; } }
<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="Domain.A, Domain" table="A"> <id name="ID" column="ID" type="string"> <generator class="uuid.hex" /> </id> <property name="Name" /> <property name="LastTime" /> </class> </hibernate-mapping> <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="Domain.B, Domain" table="B"> <id name="ID" column="ID" type="string"> <generator class="uuid.hex" /> </id> <property name="LastTime" /> <property name="Name" /> </class> </hibernate-mapping>
protected void btnSave_Click(object sender, EventArgs e) { A a = new A(); a.Name = GetB(); UtilityDao.SaveOrUpdate(a);//保存A实体 } private string GetB() { string result = string.Empty; B b = service.GetBMethod(); if(b != null) { result = b.Name; } return result; }