i have 2 table, Topic and Comment..
TOPIC
IdTopic
TopicName
CreatedOn
CreatedBy
COMMENT
IdComment
IdTopic(FK)
Comment
ReplayOn
ReplayBy
I want to count all comment where Comment.IdTopic == Topic.IdTopic
cant u help me?
i'm using Linq to sql and C#
thx,

Guest UserRank #1,422 · 1.2K reputationPosted Feb 4, 2011, 10:11 AM EST
(that's the sql solution)
Sam HobbsRank #107 · 20.5K reputationPosted Feb 4, 2011, 1:39 PM EST
kieky bouvier57 reputationPosted Feb 5, 2011, 7:45 AM EST
finally i've got the answer.. count all comment using linq sql and c#
protected String GetCountComment(string IdTopic)
{
string value = String.Empty;
DMSDataAccess db = new DMSDataAccess();
var comment = db.DMSDataContext.Comments.Where(p => Convert.ToString(p.IdTopic) == IdTopic);
value = Convert.ToString(comment.Count());
return value;
}
Sam HobbsRank #107 · 20.5K reputationPosted Feb 5, 2011, 9:18 AM EST