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,
Sam HobbsPosted Feb 5, 2011, 2:18 PM
kieky bouvierPosted Feb 5, 2011, 12:45 PM
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 HobbsPosted Feb 4, 2011, 6:39 PM
Guest UserPosted Feb 4, 2011, 3:11 PM
(that's the sql solution)