<set name="UserSystemCases" table="`User_SystemCase`" cascade="all" generic="true" inverse="true" lazy="false"> <key column="caseid" foreign-key="PK_User_SystemCase" /> <one-to-many class="UserSystemCase" /> </set>
SystemCase.hbm.xml
SystemCase.cs
/* using MyGeneration/Template/NHibernate (c) by Sharp 1.4 based on OHM (alvy77@hotmail.com) */ using System; using System.Collections; using System.Collections.Generic; using Iesi.Collections.Generic; namespace wzsckj.com.Journal.Model { /// <summary> /// ISystemCase interface for NHibernate mapped table 'SystemCase'. /// </summary> public interface ISystemCase { #region Public Properties int Id { get ; set ; } int? Pindex { get ; set ; } int? Parentid { get ; set ; } int? Caseid { get ; set ; } string Casename { get ; set ; } DateTime? Pubdate { get ; set ; } int? Userid { get ; set ; } bool? IsShowFlag { get ; set ; } string CaseData { get ; set ; } int? CaseDataTypeid { get ; set ; } bool IsDeleted { get; set; } bool IsChanged { get; set; } ISet<UserSystemCase> UserSystemCases { get; set; } #endregion } /// <summary> /// SystemCase object for NHibernate mapped table 'SystemCase'. /// </summary> [Serializable] public class SystemCase : ICloneable,ISystemCase { #region Member Variables protected int _id; protected int? _pindex; protected int? _parentid; protected int? _caseid; protected string _casename; protected DateTime? _pubdate; protected int? _userid; protected bool? _isshowflag; protected string _casedata; protected int? _casedatatypeid; protected bool _bIsDeleted; protected bool _bIsChanged; private ISet<UserSystemCase> _UserSystemCase; #endregion #region Constructors public SystemCase() {} public SystemCase(int? pPindex, int? pParentid, int? pCaseid, string pCasename, DateTime? pPubdate, int? pUserid, bool? pIsShowFlag, string pCaseData, int? pCaseDataTypeid,ISet<UserSystemCase> pUserSystemCase) { this._pindex = pPindex; this._parentid = pParentid; this._caseid = pCaseid; this._casename = pCasename; this._pubdate = pPubdate; this._userid = pUserid; this._isshowflag = pIsShowFlag; this._casedata = pCaseData; this._casedatatypeid = pCaseDataTypeid; this._UserSystemCase =pUserSystemCase; } public SystemCase(int pId) { this._id = pId; } #endregion #region Public Properties public virtual int Id { get { return _id; } set { _bIsChanged |= (_id != value); _id = value; } } public virtual int? Pindex { get { return _pindex; } set { _bIsChanged |= (_pindex != value); _pindex = value; } } public virtual int? Parentid { get { return _parentid; } set { _bIsChanged |= (_parentid != value); _parentid = value; } } public virtual int? Caseid { get { return _caseid; } set { _bIsChanged |= (_caseid != value); _caseid = value; } } public virtual string Casename { get { return _casename; } set { if (value != null && value.Length > 50) throw new ArgumentOutOfRangeException("Casename", "Casename value, cannot contain more than 50 characters"); _bIsChanged |= (_casename != value); _casename = value; } } public virtual DateTime? Pubdate { get { return _pubdate; } set { _bIsChanged |= (_pubdate != value); _pubdate = value; } } public virtual int? Userid { get { return _userid; } set { _bIsChanged |= (_userid != value); _userid = value; } } public virtual bool? IsShowFlag { get { return _isshowflag; } set { _bIsChanged |= (_isshowflag != value); _isshowflag = value; } } public virtual string CaseData { get { return _casedata; } set { if (value != null && value.Length > 250) throw new ArgumentOutOfRangeException("CaseData", "CaseData value, cannot contain more than 250 characters"); _bIsChanged |= (_casedata != value); _casedata = value; } } public virtual int? CaseDataTypeid { get { return _casedatatypeid; } set { _bIsChanged |= (_casedatatypeid != value); _casedatatypeid = value; } } public ISet<UserSystemCase> UserSystemCases { get { return _UserSystemCase; } set { _UserSystemCase = value; } } public bool IsDeleted { get { return _bIsDeleted; } set { _bIsDeleted = value; } } public bool IsChanged { get { return _bIsChanged; } set { _bIsChanged = value; } } #endregion #region Equals And HashCode Overrides /// <summary> /// local implementation of Equals based on unique value members /// </summary> public override bool Equals( object obj ) { if( this == obj ) return true; SystemCase castObj = null; try { castObj = (SystemCase)obj; } catch(Exception) { return false; } return ( castObj != null ) && ( this._id == castObj.Id ); } /// <summary> /// local implementation of GetHashCode based on unique value members /// </summary> public override int GetHashCode() { int hash = 57; hash = 27 * hash * _id.GetHashCode(); return hash; } #endregion #region ICloneable methods public object Clone() { return this.MemberwiseClone(); } #endregion } #region Custom ICollection interface for SystemCase public interface ISystemCaseCollection : ICollection { SystemCase this[int index]{ get; set; } void Add(SystemCase pSystemCase); void Clear(); } [Serializable] public class SystemCaseCollection : ISystemCaseCollection { private IList<SystemCase> _arrayInternal; public SystemCaseCollection() { _arrayInternal = new List<SystemCase>(); } public SystemCaseCollection( IList<SystemCase> pSource ) { _arrayInternal = pSource; if(_arrayInternal == null) { _arrayInternal = new List<SystemCase>(); } } public SystemCase this[int index] { get { return _arrayInternal[index]; } set { _arrayInternal[index] = value; } } public int Count { get { return _arrayInternal.Count; } } public bool IsSynchronized { get { return false; } } public object SyncRoot { get { return _arrayInternal; } } public void CopyTo(Array array, int index){ _arrayInternal.CopyTo((SystemCase[])array, index); } public IEnumerator GetEnumerator() { return _arrayInternal.GetEnumerator(); } public void Add(SystemCase pSystemCase) { _arrayInternal.Add(pSystemCase); } public void Clear() { _arrayInternal.Clear(); } public IList<SystemCase> GetList() { return _arrayInternal; } } #endregion }
调用代码
For Each sc As SystemCase In lists For Each usc As UserSystemCase In sc.UserSystemCases Response.Write(usc.Caseid) Next Next
为什么, 没有内容。奇怪,请高手指点,搞了很长时间了,没有事出来。哎