I have RadioButtonList
<asp:RadioButtonList ID="rdoRating" runat="server"
RepeatDirection="Horizontal"
Height="33px" Width="249px">
<asp:ListItem Value="1">Brilliant</asp:ListItem>
<asp:ListItem Value="2">Interesting</asp:ListItem>
<asp:ListItem Value="3">Poor</asp:ListItem>
</asp:RadioButtonList>
I want to show the number of people selected (count) Brilliant or Interesting or Poor such as " 0 Brilliant(56) 0 Interesting(88) 0 Poor(12)" 0 represent radiobutton
I want to show this count on PageLoad event
AND
select COUNT(Rating) from CommentTable where Rating = 'Interesting'
It is SQL Query but i want LINQ Query
Plz help me i am new to this Field..开发者_开发百科
If it's just a simple Linq version of that SQL you need... then you just want to use something like:
// select COUNT(Rating) from CommentTable where Rating = 'Interesting'
var result = db.Comments
.Where(comment => comment.Rating == "Interesting")
.Count();
However, I think you can do much, much better if you spend some time to think about the SQL and about the Linq (e.g. you should be able to fetch all three counts with one query using a Group By
). If what you want is a good introduction to Linq and/or the Entity Framework, then try some links like:
- http://www.informit.com/articles/article.aspx?p=1237071
- http://msdn.microsoft.com/en-us/library/bb399567.aspx
- http://odetocode.com/articles/737.aspx
Take your time and you'll learn to love Linq - it really is superb!
精彩评论