public TermVo GetTermInfo(string userid) { ITTermMsDao dao = ComponentLocator.Instance().Resolve <ITTermMsDao>(); TTermMs termms = dao.getTermbyUserId(userid); if (termms == null) { return(null); } else { TermVo termvo = new TermVo(); PropertiesCopier.CopyProperties(termms, termvo); return(termvo); } }
public TTermMs getTermbyUserId(string userid) { TTermMs termms = null; ISession ss = holder.CreateSession(typeof(TTermMsDaoOracleImp)); ITransaction tran = ss.BeginTransaction(); try { //result = (IList<MFunctioncatalog>)FindAll(typeof(MFunctioncatalog)); ScalarQuery <TTermMs> q = new ScalarQuery <TTermMs>(typeof(TTermMs), @" from TTermMs where IUserId=:userId"); q.SetParameter("userId", userid); termms = q.Execute(); //FindByPrimaryKey找不到数据的时候是抛出ActiveRecordException,不太好处理 //termms = (TTermMs)FindByPrimaryKey(typeof(TTermMs), userid); } catch (Castle.ActiveRecord.Framework.ActiveRecordException ex) { tran.Rollback(); throw new ApplicationException(ex.Message, ex); } catch (DbException ex) { tran.Rollback(); throw new ApplicationException(ex.Message, ex); } finally { tran.Dispose(); holder.ReleaseSession(ss); } return(termms); }