-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
42 lines (36 loc) · 1.3 KB
/
Program.cs
File metadata and controls
42 lines (36 loc) · 1.3 KB
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
36
37
38
39
40
41
42
//using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Linq;
//using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace QueryIt
{
class Program
{
static void Main(string[] args)
{
//var repository = new Repository<Employee>(); // talks to real database!
//AddEmployee(repository);
//AddManager(repository);
//CountEmployees(repository);
//PrintAllPeople(repository);
using (IRepository<Employee> employeeRepository = new SqlRepository<Employee>(new EmployeeDb()))
{
AddEmployees(employeeRepository);
CountEmployees(employeeRepository);
}
}
private static void CountEmployees(IRepository<Employee> employeeRepository)
{
var all = employeeRepository.FindAll().Count();
Console.WriteLine(all);
}
private static void AddEmployees(IRepository<Employee> employeeRepository)
{
employeeRepository.Add(new Employee { Name = "Scott" });
employeeRepository.Add(new Employee { Name = "Danny" });
employeeRepository.Add(new Employee { Name = "Robert" });
employeeRepository.Commit();
Console.WriteLine();
}
}
}