0

i need help in converting this SQL statement into a linq expression

        select user_ID, ticket_type, count (ticket_type) as Total

        FROM database

        group by user_ID, ticket_type

        order by user_ID, ticket_type

i got stuck when i was trying to write 2 group by in linq expression

var list2 = from p in list
            group p.Ticket.user_ID by p.Ticket.user_id;
            group p.Ticket.ticket_type by p.Ticket.ticket_type

can anyone help?

user1166085
  • 617
  • 3
  • 12
  • 23
  • Do something like this `var list2 - list.GroupBy(x => new { x.user_ID, x.ticket_type })` – Aruna Apr 28 '17 at 08:39

1 Answers1

0

var list2 = list.select(p).GroupBy(p => p.user_ID, p => p.ticket_type).OrderByDescending(g => user_ID).ToList()