/// <summary> /// page /// </summary> /// <typeparam name="T">entity type</typeparam> /// <param name="countSqlId">count sql id</param> /// <param name="pageSqlId">page sql id</param> /// <param name="pageIndex">page index</param> /// <param name="pageSize">page size</param> /// <param name="pmsDict">parameters</param> /// <param name="total">total</param> /// <returns>rows</returns> public List <T> Page <T>(string countSqlId, string pageSqlId, int pageIndex, int pageSize, out int total, Dictionary <string, object> pmsDict = null) where T : class { pmsDict = pmsDict == null ? new Dictionary <string, object>() : pmsDict; if (pmsDict.Keys.Contains("pageIndex")) { pmsDict["pageIndex"] = pageIndex; } else { pmsDict.Add("pageIndex", pageIndex); } if (pmsDict.Keys.Contains("pageSize")) { pmsDict["pageSize"] = pageSize; } else { pmsDict.Add("pageSize", pageSize); } total = ConvertTool.GetInt(QueryObj(FetchSqlFileNameByType <T>(), countSqlId, pmsDict)); List <T> res = Read <T>(pageSqlId, pmsDict); if (total > 0 && res != null && res.Count > 0) { return(res); } else { total = 0; return(null); } }
/// <summary> /// count by parameters /// </summary> /// <param name="sqlFileName">sql file name</param> /// <param name="sqlId">sql id</param> /// <param name="pmsDict">parameters</param> /// <returns>count quantity</returns> public int Count(string sqlFileName, string sqlId, Dictionary <string, object> pmsDict = null) { object obj = QueryObj(sqlFileName, sqlId, pmsDict); return(ConvertTool.GetInt(obj)); }
/// <summary> /// count by parameters /// </summary> /// <typeparam name="T">type</typeparam> /// <param name="sqlId">sql id</param> /// <param name="entity">parameter entity</param> /// <returns>count quantity</returns> public int Count <T>(string sqlId, T entity) where T : class { object obj = QueryObj(FetchSqlFileNameByType <T>(), sqlId, ConvertEntityToParameters <T>(entity)); return(ConvertTool.GetInt(obj)); }
/// <summary> /// load all setting /// </summary> internal static void LoadSetting() { BasicConfigLoaded = true; string styleXPath = "/DbConfig/DbStyle"; string trustedXPath = "/DbConfig/DbTrusted"; string hostXPath = "/DbConfig/DbHost"; string userXPath = "/DbConfig/DbUser"; string passwordXPath = "/DbConfig/DbPassword"; string portXPath = "/DbConfig/DbPort"; string instanceXPath = "/DbConfig/DbInstance"; string nameXPath = "/DbConfig/DbName"; string embedXPath = "/DbConfig/DbEmbed"; string positionXPath = "/DbConfig/DbPosition"; string dbStyle = XmlTool.GetNodeValueByXPath(styleXPath, _path); switch (dbStyle.ToLower()) { case "sqlserver": DbStyle = DbStyleDefine.SqlServer; break; case "oracle": DbStyle = DbStyleDefine.Oracle; break; case "postgres": DbStyle = DbStyleDefine.Postgres; break; case "mysql": DbStyle = DbStyleDefine.MySql; break; case "firebird": DbStyle = DbStyleDefine.Firebird; break; case "sqlite": DbStyle = DbStyleDefine.Sqlite; break; case "access": DbStyle = DbStyleDefine.Access; break; default: DbStyle = DbStyleDefine.MySql; break; } DbTrusted = ConvertTool.GetBool(XmlTool.GetNodeValueByXPath(trustedXPath, _path)); DbHost = XmlTool.GetNodeValueByXPath(hostXPath, _path); DbUser = XmlTool.GetNodeValueByXPath(userXPath, _path); DbPassword = XmlTool.GetNodeValueByXPath(passwordXPath, _path); DbPort = ConvertTool.GetInt(XmlTool.GetNodeValueByXPath(portXPath, _path)); if (DbPort > 65535) { DbPort = 65534; XmlTool.SetNodeValueByXPath(portXPath, DbPort.ToString(), _path); } DbInstance = XmlTool.GetNodeValueByXPath(instanceXPath, _path); DbName = XmlTool.GetNodeValueByXPath(nameXPath, _path); DbEmbed = ConvertTool.GetBool(XmlTool.GetNodeValueByXPath(embedXPath, _path)); DbPosition = XmlTool.GetNodeValueByXPath(positionXPath, _path); }