1

コントローラで以下のメソッドを呼び出しています。

 var comments = _blogService.GetBlogComments(bc.CommentParentID);//Controller code

クラスコード:

public virtual IList<BlogComment> GetBlogComments(int CommentParentId)
        {
            if (CommentParentId != 0)
            {
                var query = from bc in _blogCommentRepository.Table
                            where bc.CommentParentID == CommentParentId
                            select bc;

                var comments = query.ToList();
                return comments;
            }
            else
                return null;
        }

エラーが発生します

var query = from bc in _blogCommentRepository.Table
                            where bc.CommentParentID == CommentParentId
                            select bc;][1]

http://i.stack.imgur.com/uMWcV.jpg

4

1 に答える 1

1

バインドする最初のことは、メソッド_blogCommentRepository内で使用している変数がであるということです。したがって、この変数を使用する前に、この変数が初期化されていることを確認してください。GetBlogCommentsnull

_blogCommentRepository = new ...
于 2013-01-02T06:52:52.927 に答える