-
Notifications
You must be signed in to change notification settings - Fork 3
/
Launcher.cs
35 lines (32 loc) · 1003 Bytes
/
Launcher.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Linq;
using P02_DatabaseFirst.Data;
namespace AddressesByTown
{
public class Launcher
{
public static void Main()
{
SoftUniContext db = new SoftUniContext();
using (db)
{
var selectedAddresses = db.Addresses
.OrderByDescending(a => a.Employees.Count)
.ThenBy(a => a.Town.Name)
.ThenBy(a => a.AddressText)
.Take(10)
.Select(a => new
{
Text = a.AddressText,
Town = a.Town.Name,
EmployeesCount = a.Employees.Count
})
.ToList();
foreach (var address in selectedAddresses)
{
Console.WriteLine($"{address.Text}, {address.Town} - {address.EmployeesCount} employees");
}
}
}
}
}