/// <summary> /// 伪删除 /// </summary> /// <returns></returns> public static Int32 FakeDeleteById(PK id) { Type tt = typeof(T); string hql = "Update " + tt.Name + " Set deleted=1 Where id=?"; object count = ActiveRecordBase <T> .Execute( delegate(NHibernate.ISession session, object instance) { NHibernate.IQuery iQuery = session.CreateQuery(hql); iQuery.SetParameter(0, id); return(iQuery.ExecuteUpdate()); }, null); return((int)count); }
/// <summary> /// 按SQL查询 /// </summary> /// <param name="sql"></param> /// <param name="_sqlParams"></param> /// <returns></returns> public static IList FindBySql(string sql, object[] _sqlParams) { IList rst = (IList)ActiveRecordBase <T> .Execute( delegate(NHibernate.ISession session, object instance) { NHibernate.ISQLQuery iSQLQuery = session.CreateSQLQuery(sql); if (_sqlParams != null && _sqlParams.Length > 0) { for (int i = 0; i < _sqlParams.Length; i++) { iSQLQuery.SetParameter(i, _sqlParams[i]); } } return(iSQLQuery.List()); }, null); return(rst); }