Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have studentno field in my table, i want sum of all the student,so plz help me in doing that in LinQ C#
Posted
Comments
bbirajdar 5-Dec-12 4:08am    
" i want sum of all the student"

You cannot have SUM of students.. You can have sum of marks or count of students

Try this:
C#
FROM p in m.Items
group p by p.Id into g
select new
{
    SumTotal = g.Sum(x => x.Total),
    SumDone = g.Sum(x => x.Done)
};

Found it here[^]

Check out:
link 1[^]
link 2[^]
 
Share this answer
 
MSDN[^] will help you :)
 
Share this answer
 
i not get your question clearly i think u want to count number of student in that case
write query like

var id=(from a in linq_obj.tablename
select a).Tolist();
int count=id.count();

in this count give u no of student
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900