i have list of nominee and i want to check each one of them if he have the most numbers of vote then i can store him in variable as a winner
how can i do that?
var p = db1.Nominees.Where((x => x.position == s)).ToList();
var count = db1.Nominees.Where(x => x.position.Equals(s)).Count();
int v = p.FirstOrDefault(x => x.num_vote);
foreach ( var i in p)
{
You can get the max data first and search by this max data, like:
var max = _context.Nominees.Max(x => x.votenum);
var maxobj = _context.Nominees.Where(x => x.votenum == max).ToList();
Best Regards,
Jerry Cai
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
5 Points
18 Posts
code of entity data model
Feb 04, 2021 08:25 AM|samaremad|LINK
hello everyone please help me
i have list of nominee and i want to check each one of them if he have the most numbers of vote then i can store him in variable as a winner
how can i do that?
var p = db1.Nominees.Where((x => x.position == s)).ToList();
var count = db1.Nominees.Where(x => x.position.Equals(s)).Count();
int v = p.FirstOrDefault(x => x.num_vote);
foreach ( var i in p)
{
}
Participant
970 Points
315 Posts
Re: code of entity data model
Feb 05, 2021 02:47 AM|Jerry Cai|LINK
Hi, samaremad
You can get the max data first and search by this max data, like:
var max = _context.Nominees.Max(x => x.votenum); var maxobj = _context.Nominees.Where(x => x.votenum == max).ToList();
Best Regards,
Jerry Cai