NHibernate 根据Model ID获取对象

 public virtual DemissionRemittanceInfo GetDemissionRemittanceInfo(int demissionremittanceID)
        {
            using (ISession session = OpenSession())
            {
                return (DemissionRemittanceInfo)NHibernateHelper.GetObject(session, typeof(DemissionRemittanceInfo), demissionremittanceID);
            }
        }

 

    public virtual DemissionRemittanceInfo GetDemissionRemittanceInfoByDemissionID(int demissionID)
        {
            using (ISession session = OpenSession())
            {
                ArrayList list = (ArrayList)session.CreateCriteria(typeof(DemissionRemittanceInfo)).Add(Expression.Eq("DemissionID", demissionID)).List();
                if (list.Count > 0)
                    return (DemissionRemittanceInfo)list[0];
                return null;
 
            }
        }

 

posted @ 2012-08-29 23:03  Tom Fan  阅读(204)  评论(0编辑  收藏  举报