コード例 #1
0
ファイル: SQLBlogDataAccess.cs プロジェクト: xthxne/keymapper
        public Collection <Comment> GetAllComments(CommentType ctype)
        {
            using (SqlConnection connection = this.GetConnection())
            {
                connection.Open();

                SqlCommand sc = new SqlCommand("GetAllComments", connection);
                sc.CommandType = CommandType.StoredProcedure;

                Collection <Comment> clist = SqlDataMap.CreateCommentsFromReader(sc.ExecuteReader());

                return(clist);
            }
        }
コード例 #2
0
ファイル: SQLBlogDataAccess.cs プロジェクト: xthxne/keymapper
        public Collection <Comment> GetCommentsForPost(int postId, CommentType ctype)
        {
            using (SqlConnection connection = this.GetConnection())
            {
                connection.Open();

                SqlCommand sc = new SqlCommand("GetCommentsByPost", connection);
                sc.CommandType = CommandType.StoredProcedure;

                sc.Parameters.AddWithValue("PostId", postId);

                if (ctype == CommentType.All)
                {
                    sc.Parameters.AddWithValue("Approved", DBNull.Value);
                }
                else
                {
                    int bitValue = 0;

                    if (ctype == CommentType.Approved)
                    {
                        bitValue = 1;
                    }
                    else if (ctype == CommentType.UnApproved)
                    {
                        bitValue = 0;
                    }

                    sc.Parameters.AddWithValue("Approved", bitValue);
                }

                Collection <Comment> clist = SqlDataMap.CreateCommentsFromReader(sc.ExecuteReader());

                return(clist);
            }
        }