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 回答