private static void ShowList() { var sqlConnection = new System.Data.SqlClient.SqlConnection("Server=.; initial catalog=Session22DB; integrated security=true"); var personRepo = new PersonRipository(sqlConnection); var people = personRepo.GetPeople(); foreach (var item in people) { Console.WriteLine($"id: {item.PersonId} \t FirstName: {item.FirstName} \t LastName: {item.LastName}"); } }
private static void Insert() { Console.WriteLine("FirstName: "); string firstName = Console.ReadLine(); Console.WriteLine("LastName: "); string lastName = Console.ReadLine(); var sqlConnection = new System.Data.SqlClient.SqlConnection("Server=.; initial catalog=Session22DB; integrated security=true"); var personRepo = new PersonRipository(sqlConnection); personRepo.Insert(firstName, lastName); }
private static void InsertAll() { var personForImport = System.IO.File.ReadAllLines("PersonForImport.txt").Select(c => { var lst = c.Split(','); var person = new Person { FirstName = lst[0], LastName = lst[1] }; return(person); }).ToList(); var sqlConnection = new System.Data.SqlClient.SqlConnection("Server=.; initial catalog=Session22DB; integrated security=true"); var personRepo = new PersonRipository(sqlConnection); personRepo.InsertAll(personForImport); }