Note that you will need to add the reference to the Oracle.ManagedDataAccess.Client package.
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
using Dapper;
using Oracle.ManagedDataAccess.Client;
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public string Department { get; set; }
public decimal Salary { get; set; }
}
public async Task<List<Employee>> GetEmployeeListFromOracleAsync()
{
List<Employee> employees;
string connectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(HOST=hostName)(PORT=portNumber))(CONNECT_DATA=(SERVER=DEDICATED)
(SERVICE_NAME=serviceName)));User Id=userName;Password=password;";
using (IDbConnection connection = new OracleConnection(connectionString))
{
employees = (await connection.QueryAsync<Employee>("SELECT * FROM Employee")).AsList();
}
return employees;
}
No comments:
Post a Comment
Please keep your comments relevant.
Comments with external links and adult words will be filtered.