public static void AddEmployeeData() { var context = new EmployeeInfoEntities1(); var employees = new List <ITEmployee> { new ITEmployee() { FirstName = "John", LastName = "Johnson", Position = "Manager", SeperationDate = new DateTime(2016, 12, 31) }, new ITEmployee() { FirstName = "Tou", LastName = "Xiong", Position = "Software Engineer", SeperationDate = new DateTime(2016, 10, 5) }, new ITEmployee() { FirstName = "Michaela", LastName = "Michaelson", Position = "District Manager", SeperationDate = new DateTime(2015, 12, 19) }, new ITEmployee() { FirstName = "Jake", LastName = "Jacobson", Position = "Programmer" }, new ITEmployee() { FirstName = "Jacquelyn", LastName = "Jackson", Position = "DBA" }, new ITEmployee() { FirstName = "Sally", LastName = "Weber", Position = "Web Developer", SeperationDate = new DateTime(2015, 12, 18) } }; context.ITEmployee.AddRange(employees); context.SaveChanges(); }
static void Main(string[] args) { var context = new EmployeeInfoEntities1(); //ITEmployeeData.AddEmployeeData(); Console.WriteLine("Name\t\t | Position\t\t| Separation Date"); Console.WriteLine("--------------------|-------------------|----------------"); string name; foreach (var employee in context.ITEmployee .OrderBy(e => e.LastName)) { name = employee.FirstName + " " + employee.LastName; Console.WriteLine( string.Format("{0, -19} | {1, -17} | {2:yyyy-MM-dd}", name, employee.Position, employee.SeperationDate)); } Console.ReadKey(); }