public static string Csvinsert() { List <MyMappedCSVFile> values = File.ReadAllLines(@"C:\Users\Sanket\Desktop\Neudesic\CSVRecord.csv") .Skip(1) .Select(v => MyMappedCSVFile.FromCsv(v)) .ToList(); foreach (var rowl in values) { Entities _repo = new Entities(); EmployeeDetailsTable emp = new EmployeeDetailsTable(); Console.WriteLine(rowl); emp.EID = rowl.EID; emp.ENAME = rowl.Name; emp.DOB = rowl.DOB; emp.LOCATION = rowl.location; emp.DOJ = rowl.DOJ; try { _repo.EmployeeDetailsTables.Add(emp); _repo.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex.ToString() + "Warning"); } } Console.WriteLine("\n Want to enter another option ? y/n"); string choice2 = Console.ReadLine(); return(choice2); }
public static void Locationmapping(string location) { Entities _repo = new Entities(); EmployeeDetailsTable emp = new EmployeeDetailsTable(); List <EmployeeDetailsTable> query = _repo.EmployeeDetailsTables.Where(s => s.LOCATION == location).ToList(); foreach (var employeeid in query) { string formateddateofbirth = String.Format("{0:MM/dd/yyyy}", emp.DOB); string formateddateofjoining = String.Format("{0:MM/dd/yyyy}", emp.DOJ); Console.WriteLine($"EID : {employeeid.EID} NAME : {employeeid.ENAME} DOB : {emp.DOB} Location : {emp.LOCATION} DOJ : {formateddateofjoining} \n"); Console.WriteLine("---------------------------------------------------------------------------------------------------------------"); } }