public IActionResult Index() { // this is not the correct way, ideally your DAL should be getting the connection string from the appsettings.json var connStr = _configuration.GetConnectionString("ConnStr"); EmployeeAddressDetails employeeAddressDetails = new EmployeeAddressDetails(); var details = employeeAddressDetails.GetEmployees(connStr, ""); ViewBag.ConnStr = connStr; IList <Employee> list = new List <Employee>(); foreach (DataRow row in details.Rows) { Employee employee = new Employee() { EmpId = row["EmpId"].ToString(), Location = row["Location"].ToString(), Name = row["Name"].ToString(), Salary = decimal.Parse(row["Salary"].ToString()) }; list.Add(employee); } return(View(list)); }
static void Main(string[] args) { Factory factory = new Factory(); var village = factory.GetPeople(PeopleType.RURAL); Console.WriteLine(village.GetName()); var city = factory.GetPeople(PeopleType.URBAN); Console.WriteLine(city.GetName()); //SingleTon singleTon = SingleTon.Instance; //var sum = singleTon.Sum(2, 3); //Console.WriteLine(sum); //SingleTon singleTon1 = SingleTon.Instance; //sum = singleTon1.Sum(4, 3); //Console.WriteLine(sum); //SingleTon singleTon2 = SingleTon.Instance; //sum = singleTon2.Sum(8, 3); //Console.WriteLine(sum); return; Console.WriteLine("Enter EmpId to see the details:"); var empId = Console.ReadLine().ToString(); DataSet dataSet = new DataSet(); try { dataSet = new EmployeeAddressDetails().GetEmployeeAddressDetails(empId); } catch (Exception ex) { Console.WriteLine("Error occured. " + ex.ToString()); } foreach (DataRow row in dataSet.Tables[0].Rows) { Console.WriteLine(row["EmpId"] + " | " + row["Name"] + " | " + row["Salary"]); } foreach (DataRow row in dataSet.Tables[1].Rows) { Console.WriteLine(row["Address1"] + " | " + row["Address2"] + " | " + row["City"]); } }