当前位置: 首页>>代码示例>>C#>>正文


C# MySqlParameter.ToList方法代码示例

本文整理汇总了C#中MySql.Data.MySqlClient.MySqlParameter.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlParameter.ToList方法的具体用法?C# MySqlParameter.ToList怎么用?C# MySqlParameter.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MySql.Data.MySqlClient.MySqlParameter的用法示例。


在下文中一共展示了MySqlParameter.ToList方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Pages

        public List<LeaveMessage> Pages(int pageIndex, int pageSize, string conditions, out int total)
        {
            total = 0;
            var sql = @"";
            //var sql = @"SELECT * FROM leavemessage ORDER BY CreateTime DESC";
            var sql_total = @"Select Count(*) From leavemessage;";
            MySqlParameter[] paraList = new MySqlParameter[]
            {
                new MySqlParameter("@PageIndex", --pageIndex * pageSize),
                new MySqlParameter("@PageSize", pageSize)
            };

            var list = _DataBase.QueryList<LeaveMessage>(sql, paraList.ToList());
            total = _DataBase.QueryTotal(sql_total, null); //查询总数
            return list;
        }
开发者ID:qinfengwangyi,项目名称:Qin.Blog,代码行数:16,代码来源:LeaveMessageDao.cs

示例2: LogOn

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="passWord"></param>
        /// <param name="user"></param>
        /// <param name="msg"></param>
        /// <returns>登录成功返回true和User信息,失败返回false和null</returns>
        public bool LogOn(string userName, string passWord, out User user, out string msg)
        {
            int result_u = 0;
            user = null;
            msg = string.Empty;

            string sql_u = @"Select COUNT(*) Count From user Where UserName = @UserName;";
            string sql_up = @"Select * From user Where UserName = @UserName And PassWord = @PassWord;";
            MySqlParameter[] para_u = new MySqlParameter[] { new MySqlParameter("@UserName", userName) };
            MySqlParameter[] para_up = new MySqlParameter[] { new MySqlParameter("@UserName", userName), new MySqlParameter("@PassWord", passWord) };

            //验证用户是否存在
            using (var conn = DataBase.GetOpenConn4MySql())
            {
                MySqlDataReader dr = DataBase.ExecuteQueryReader(sql_u, conn, para_u);
                while (dr.Read())
                {
                    result_u = dr["Count"] != null ? Convert.ToInt32(dr["Count"]) : 0;
                }
                dr.Close();
                if (result_u <= 0)
                {
                    msg = "用户名不存在";
                    return false;
                }
            }

            //验证用户名和密码是否正确
            DataSet ds = new DataSet();
            MySqlDataAdapter da = DataBase.ExecuteQuery4MySql(sql_up, para_up.ToList());
            if (da != null)
            {
                da.Fill(ds);
            }
            if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
            {
                user = FillData.FillDataToEntity<User>(new User(), ds.Tables[0]);
                return true;
            }
            else
            {
                msg = "密码输入错误";
                return false;
            }

        }
开发者ID:qinfengwangyi,项目名称:Qin.Blog,代码行数:54,代码来源:UserDao.cs

示例3: GetArticleById

 /// <summary>
 /// 查看文章详细内容
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ArticleDBModel GetArticleById(string id)
 {
     var sql = @"Select a.*,b.NickName,b.Sex,b.UserName From article a LEFT JOIN user b ON a.UserId = b.Id Where 1=1 And a.Id = @Id;UPDATE article SET ViewCount=ViewCount+1 WHERE Id = @Id;";
     MySqlParameter[] para = new MySqlParameter[] { new MySqlParameter("@Id", id) };
     return _DataBase.QueryModel<ArticleDBModel>(sql, para.ToList());
 }
开发者ID:qinfengwangyi,项目名称:Qin.Blog,代码行数:11,代码来源:ArticleDao.cs

示例4: GetUserArticles

 /// <summary>
 /// 查询用户的文章列表
 /// </summary>
 /// <param name="userName"></param>
 /// <param name="total"></param>
 /// <returns></returns>
 public List<Article> GetUserArticles(string userId, out int total)
 {
     string sql = @"Select * From article Where UserId = @UserId Order By CreateTime Desc;";
     string sql_total = @"Select Count(*) From article Where UserId = @UserId";
     MySqlParameter[] para = new MySqlParameter[]
     {
         new MySqlParameter("@UserId", userId),
     };
     var list = _DataBase.QueryList<Article>(sql, para.ToList());
     var totallist = _DataBase.QueryTotal(sql_total, para.ToList());
     total = totallist;
     return list;
 }
开发者ID:qinfengwangyi,项目名称:Qin.Blog,代码行数:19,代码来源:ArticleDao.cs

示例5: Pages

        /// <summary>
        /// 分页查询(无条件)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="conditions"></param>
        /// <param name="total"></param>
        /// <returns>没有数据的返回null</returns>
        public List<Article> Pages(int pageIndex, int pageSize, string userId, out int total)
        {
            if (pageIndex <= 1)
                pageIndex = 1;
            total = 0;
            var sql = @"SELECT
	                        a.*, b.NickName,
	                        b.Sex,
	                        b.UserName
                        FROM
	                        article a
                        LEFT JOIN USER b ON a.UserId = b.Id
                        WHERE
	                        UserId = @UserId
                        ORDER BY
	                        IsTop DESC,
	                        CreateTime DESC
                        LIMIT @PageIndex,
                         @PageSize;";
            MySqlParameter[] para = new MySqlParameter[]
            {

                new MySqlParameter("@PageIndex", --pageIndex*10),
                new MySqlParameter("@PageSize", pageSize)
            };
            var list = _DataBase.QueryList<Article>(sql, para.ToList());

            var sql_total = @"SELECT
	                            a.*, b.NickName,
	                            b.Sex,
	                            b.UserName
                            FROM
	                            article a
                            LEFT JOIN USER b ON a.UserId = b.Id
                            WHERE
	                            UserId = @UserId";

            DataSet ds = _DataBase.GetPage4MySql(new Article(), pageIndex, pageSize);
            DataTable pages = ds.Tables[0];
            total = _DataBase.QueryTotal(sql_total, para.ToList());
            return list;
        }
开发者ID:qinfengwangyi,项目名称:Qin.Blog,代码行数:50,代码来源:ArticleDao.cs

示例6: LeaveMsgPages

        public List<LeaveMsgDBModel> LeaveMsgPages(int pageIndex, int pageSize, string conditions, out int total)
        {
            var sql = @"SELECT
	                        a.Id,
	                        a.ParentId,
	                        a.Content,
	                        a.UserId,
	                        CASE WHEN c.UserName is NULL THEN '游客'
	                        ELSE c.NickName END as NickName,
	                        b.Id PId,
	                        b.ParentId PParentId,
	                        b.Content PContent,
	                        b.UserId PUserId,
	                        CASE WHEN d.UserName is NULL THEN '游客'
	                        ELSE d.NickName END as PNickName,
	                        a.CreateTime,
	                        CASE WHEN b.CreateTime is NULL THEN a.CreateTime
	                        ELSE b.CreateTime END as  PCreateTime
                        FROM
	                        leavemessage a
                        LEFT JOIN leavemessage b ON a.ParentId = b.Id
                        LEFT JOIN `user` c ON a.UserId = c.Id
                        LEFT JOIN `user` d ON b.UserId = d.Id
                        ORDER BY
	                        a.CreateTime DESC LIMIT @PageIndex,@PageSize;";
            var sql_total = @"Select Count(*) From leavemessage;";
            MySqlParameter[] paraList = new MySqlParameter[]
            {
                new MySqlParameter("@PageIndex", --pageIndex * pageSize),
                new MySqlParameter("@PageSize", pageSize)
            };

            var list = _DataBase.QueryList<LeaveMsgDBModel>(sql, paraList.ToList());
            total = _DataBase.QueryTotal(sql_total, null); //查询总数
            return list;
        }
开发者ID:qinfengwangyi,项目名称:Qin.Blog,代码行数:36,代码来源:LeaveMessageDao.cs

示例7: CommentPages

        /// <summary>
        /// 文章的评论列表
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="articleId"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public List<CommentDBModel> CommentPages(int pageIndex, int pageSize, string articleId, out int total)
        {
            total = 0;
            var sql = @"SELECT
							a.ArticleId,
	                        a.Id,
	                        a.ParentId,
	                        a.Content,
	                        a.UserId,
	                        CASE WHEN c.UserName is NULL THEN '游客'
	                        ELSE c.NickName END as NickName,
	                        b.Id PId,
	                        b.ParentId PParentId,
	                        b.Content PContent,
	                        b.UserId PUserId,
	                        CASE WHEN d.UserName is NULL THEN '游客'
	                        ELSE d.NickName END as PNickName,
	                        a.CreateTime,
	                        CASE WHEN b.CreateTime is NULL THEN a.CreateTime
	                        ELSE b.CreateTime END as  PCreateTime
                        FROM
	                        `comment` a
                        LEFT JOIN `comment` b ON a.ParentId = b.Id
                        LEFT JOIN `user` c ON a.UserId = c.Id
                        LEFT JOIN `user` d ON b.UserId = d.Id
                        WHERE a.ArticleId = @ArticleId
                        ORDER BY
	                        a.CreateTime DESC LIMIT @PageIndex,@PageSize";
            var sql_total = @"Select Count(*) From comment WHERE ArticleId = @ArticleId;";
            MySqlParameter[] paraList = new MySqlParameter[]
            {
                new MySqlParameter("@ArticleId", articleId),
                new MySqlParameter("@PageIndex", --pageIndex * pageSize),
                new MySqlParameter("@PageSize", pageSize)
            };

            var list = _DataBase.QueryList<CommentDBModel>(sql, paraList.ToList());
            total = _DataBase.QueryTotal(sql_total, paraList.ToList()); //查询总数
            return list;
        }
开发者ID:qinfengwangyi,项目名称:Qin.Blog,代码行数:48,代码来源:CommentDao.cs

示例8: EditPwd

        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="id"></param>
        /// <param name="passWord"></param>
        /// <returns></returns>
        public bool EditPwd(string id, string oldPwd, string newPwd, out string msg)
        {
            msg = "修改失败!";
            var sql_oldpwd = @"Select * From user Where [email protected] And [email protected]";
            MySqlParameter[] para = new MySqlParameter[]
            {
                new MySqlParameter("@Id", id),
                new MySqlParameter("@OldPwd", oldPwd)
            };
            var result = _DataBase.QueryModel<User>(sql_oldpwd, para.ToList());
            if (string.IsNullOrEmpty(result.Id))
            {
                msg = "原密码输入错误!";
                return false;
            }

            var sql = @"Update user Set [email protected] Where [email protected]";
            MySqlParameter[] paras = new MySqlParameter[]
            {
                new MySqlParameter("@PassWord", newPwd),
                new MySqlParameter("@Id", id)
            };
            if (DataBase.ExecuteNonQuery4MySql(sql, paras.ToList()) > 0)
            {
                msg = "修改成功!";
                return true;
            }
            return false;
        }
开发者ID:qinfengwangyi,项目名称:Qin.Blog,代码行数:35,代码来源:UserDao.cs

示例9: Exsit

        /// <summary>
        /// 检查名称是否存在
        /// </summary>
        /// <param name="keyWord"></param>
        /// <returns></returns>
        public bool Exsit(string keyWord)
        {
            string sql = @"Select * From user Where UserName = @UserName;";
            MySqlParameter[] para = new MySqlParameter[] { new MySqlParameter("@UserName", keyWord) };
            List<User> userList = _DataBase.QueryList<User>(sql, para.ToList());
            if (userList != null && userList.Count > 0)
            {
                return true;
            }
            return false;

        }
开发者ID:qinfengwangyi,项目名称:Qin.Blog,代码行数:17,代码来源:UserDao.cs

示例10: Update

 /// <summary>
 /// 更新用户昵称和性别信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(User model)
 {
     var sql = @"Update user Set NickName = @NickName, Sex = @Sex Where Id = @Id";
     MySqlParameter[] para = new MySqlParameter[]
     {
         new MySqlParameter("@NickName", model.NickName),
         new MySqlParameter("@Sex", model.Sex),
         new MySqlParameter("@Id", model.Id)
     };
     if (DataBase.ExecuteNonQuery4MySql(sql, para.ToList()) > 0)
     {
         return 1;
     }
     return 0;
 }
开发者ID:qinfengwangyi,项目名称:Qin.Blog,代码行数:20,代码来源:UserDao.cs


注:本文中的MySql.Data.MySqlClient.MySqlParameter.ToList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。