1

LINQ 式のヘルプが必要です。2 つのテーブルがArticleあり、comments外部キーはArticle_id.今、linq to sql を使用して両方のテーブルを使用するデータが必要ですarticle_id,Article_title,Total_Comments(現在の記事の記事へのコメントの数),

物語の構造 :

table 1(Article) : Article_ID,Article_Title.. etc
table 2(comments ): Comment_auto_id,Comment_text,Comment_by(User_ID),Article_ID
4

2 に答える 2

1

そんな感じ ?

from article in Articles
join comment in Comments on article.Article_ID equals comment.ArticleID into articleComments
select new {
  Article = article,//or more detailed if you want only part of Articles entity
  Total_Comments = articleComments.Count()
}
于 2013-03-10T07:05:21.870 に答える
0

.GroupJoin() 拡張メソッドを使用する必要があるかもしれません。ソース: http://msdn.microsoft.com/en-us/library/system.linq.enumerable.groupjoin.aspx

于 2013-03-10T10:09:47.333 に答える