public Company GetByKey(string key) { using (var conn = CreateConnection()) { using (var cmd = conn.CreateCommand()) { cmd.CommandText = "select * from company where company_name = :companyName"; cmd.CommandType = CommandType.Text; cmd.Parameters.Add("companyName", OracleDbType.Varchar2).Value = key; conn.Open(); var reader = cmd.ExecuteReader(); reader.Read(); return(CompanyHelper.Map(reader)); //return company object } } }
public IEnumerable <Company> GetAll() { using (var conn = CreateConnection()) { using (var cmd = conn.CreateCommand()) { cmd.CommandText = "select * from company"; cmd.CommandType = CommandType.Text; conn.Open(); var result = new List <Company>(); var reader = cmd.ExecuteReader(); while (reader.Read()) { result.Add(CompanyHelper.Map(reader)); } return(result); } } }