/// <summary> /// 根据地址码得到AddrCode /// </summary> /// <param name="hibernateOper"></param> /// <param name="code"></param> /// <returns></returns> public static AddrCode GetAddrCode(IHibernateOper hibernateOper, string code) { AddrCode retVal = null; Exec(hibernateOper, delegate(ISession s) { //查找地址码 retVal = GetAddrCode(s, code); } ); return(retVal); }
/// <summary> /// 根据地址码得到AddrCode /// </summary> /// <param name="session"></param> /// <param name="code"></param> /// <returns></returns> public static AddrCode GetAddrCode(ISession session, string code) { AddrCode retVal = null; ICriteria criteria = session.CreateCriteria(typeof(AddrCode)); //模糊查找当前代码 ICriterion criterion = Restrictions.Eq("Code", code); criteria.Add(criterion); criterion = Restrictions.Eq("Del", false); criteria.Add(criterion); criteria.SetFirstResult(0); criteria.SetMaxResults(1); criteria.SetCacheable(true); retVal = criteria.UniqueResult <AddrCode>(); return(retVal); }