locked
code of entity data model RRS feed

  • Question

  • User-1566284277 posted

    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)
                        {


                        }

    Thursday, February 4, 2021 8:25 AM

Answers

  • User1312693872 posted

    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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 5, 2021 2:47 AM