/// <summary>得到一个对象实体 /// /// </summary> /// <param name="KeyId">主键</param> /// <returns>返回对象实体</returns> public Nikita.Assist.CodeMaker.Model.Sys_Roles GetModel(int KeyId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from Sys_Roles "); strSql.Append(" where KeyId=@KeyId "); DataAccess4DBHelper.IDbHelper h = GlobalHelpDemoForm.GetDataAccessHelperDemo(); h.CreateCommand(strSql.ToString()); h.AddParameter("@KeyId", KeyId); Nikita.Assist.CodeMaker.Model.Sys_Roles model = null; using (IDataReader dataReader = h.ExecuteReader()) { if (dataReader.Read()) { model = ReaderBind(dataReader); } h.CloseConn(); } return(model); }
/// <summary>根据条件得到一个对象实体 /// /// </summary> /// <param name="strCond">条件</param> /// <returns>返回对象实体</returns> public Nikita.Assist.CodeMaker.Model.Sys_Roles GetModelByCond(string strCond) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from Sys_Roles "); if (!string.IsNullOrEmpty(strCond)) { strSql.Append(" where " + strCond); } DataAccess4DBHelper.IDbHelper h = GlobalHelpDemoForm.GetDataAccessHelperDemo(); h.CreateCommand(strSql.ToString()); Nikita.Assist.CodeMaker.Model.Sys_Roles model = null; using (IDataReader dataReader = h.ExecuteReader()) { if (dataReader.Read()) { model = ReaderBind(dataReader); } h.CloseConn(); } return(model); }
/// <summary>分页获取数据列表 /// /// </summary> /// <param name="strFields">字段</param> /// <param name="strOrder">排序</param> /// <param name="strOrderType">排序类型</param> /// <param name="intPageSize">每页大小</param> /// <param name="intPageIndex">当前第N页</param> /// <param name="strWhere">条件</param> /// <returns>返回符合条件的对象集合</returns> public List <Nikita.Assist.CodeMaker.Model.Sys_Roles> GetListArray(string strFields, string strOrder, string strOrderType, int intPageSize, int intPageIndex, string strWhere) { DataAccess4DBHelper.IDbHelper h = GlobalHelpDemoForm.GetDataAccessHelperDemo(); h.CreateStoredCommand("[proc_SplitPage]"); h.AddParameter("@tblName", "Sys_Roles"); h.AddParameter("@strFields", strFields); h.AddParameter("@strOrder", strOrder); h.AddParameter("@strOrderType", strOrderType); h.AddParameter("@PageSize", intPageSize); h.AddParameter("@PageIndex", intPageIndex); h.AddParameter("@strWhere", strWhere); List <Nikita.Assist.CodeMaker.Model.Sys_Roles> list = new List <Nikita.Assist.CodeMaker.Model.Sys_Roles>(); using (IDataReader dataReader = h.ExecuteReader()) { while (dataReader.Read()) { list.Add(ReaderBind(dataReader)); } h.CloseConn(); } return(list); }
/// <summary>获得数据列表(比DataSet效率高,推荐使用) /// /// </summary> /// <param name="strWhere">条件</param> /// <returns>返回符合条件的对象集合</returns> public List <Nikita.Assist.CodeMaker.Model.Sys_Roles> GetListArray(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * "); strSql.Append(" FROM Sys_Roles "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } List <Nikita.Assist.CodeMaker.Model.Sys_Roles> list = new List <Nikita.Assist.CodeMaker.Model.Sys_Roles>(); DataAccess4DBHelper.IDbHelper h = GlobalHelpDemoForm.GetDataAccessHelperDemo(); h.CreateCommand(strSql.ToString()); using (IDataReader dataReader = h.ExecuteReader()) { while (dataReader.Read()) { list.Add(ReaderBind(dataReader)); } h.CloseConn(); } return(list); }