2013-01-20 39 views
14

私はユーザー名とコメントを表示するためのデータリストを使用し、その下の各コメントのユーザー名を添付します。 私はコメントを表示するためのユーザーコントロールReviewListとその中にefilesを持っています。しかし、私はこの行にエラーがあります(s.tblDraft.Comments)。エラーが発生しました:IEnumerableは型引数で使用できません

The non-generic type 'System.Collections.IEnumerable' cannot be used with type arguments 

問題の原因を助けてください。コンパイラが見

private void Displayuser() 
{ 
    var reviews = 
     (from s in _DataContext.tblSends 
     from u in _DataContext.Users 

     where (s.DraftId == _Draftid) && (s.ToEmailId == u.ID) 
     orderby u.Name 
     select new 
{ 
    userid = u.ID, 
    username = u.Name, 
    comments =s.tblDraft.Comments, 
    w = s.tblDraft.Comments.SelectMany(q => q.CommentAttaches) 

}).Distinct(); 

    DataList1.DataSource = reviews; 
    DataList1.DataBind(); 

    var theReview = reviews.Single(); 

    DisplayReviews(theReview.comments, theReview.w); 
} 

private void DisplayReviews(IEnumerable<Comment> comments, 
    IEnumerable<CommentAttach> w) 
{ 
    ReviewList reviewList = (ReviewList)DataList1.FindControl("ReviewList1"); 
    reviewList.Comments = comments; 
    reviewList.CommentAttachs = w; 
    reviewList.DataBind(); 
} 

答えて

36

タイプは、非ジェネリックのIEnumerableあるSystem.Collections.IEnumerableです。その名前空間をインポートしたので、これはコンパイラが使用しようとしていると思うタイプです。

使用しようとしているタイプはSystem.Collections.Generic.IEnumerable<T>です。その名前空間のインポートを追加すると、物事はコンパイルする必要があります。

+0

良いもの!また、Resharperのようなツールを使用している場合は、この修正が提案されます。 –

関連する問題