public static List <Cliente> BuscarClientes() { string Query = "SELECT Cli.Id as Id, Tel.Numero as Telefone, RG, CPF, Email, Nome" + " FROM Clientes Cli JOIN Telefones Tel ON Tel.ClienteId = Cli.Id;"; using (_handyMan = new BdHandyMan()) { var retorno = _handyMan.ExecutaComandoComRetorno(Query); return(retorno.ReaderToListaCliente()); } }
public static Cliente BuscarClientePorId(int Id) { string Query = $"SELECT * FROM Clientes WHERE Id = {Id};"; Cliente cliente = null; using (_handyMan = new BdHandyMan()) { var retorno = _handyMan.ExecutaComandoComRetorno(Query); cliente = retorno.ReaderToCliente(); } Query = $"SELECT * FROM Telefones WHERE ClienteId = {Id};"; Telefone telefone = null; using (_handyMan = new BdHandyMan()) { var retorno = _handyMan.ExecutaComandoComRetorno(Query); telefone = retorno.ReaderToTelefone(); } Query = $"SELECT * FROM Enderecos WHERE ClienteId = {Id};"; Endereco endereco = null; using (_handyMan = new BdHandyMan()) { var retorno = _handyMan.ExecutaComandoComRetorno(Query); endereco = retorno.ReaderToEndereco(); } cliente.Telefone = telefone; cliente.Endereco = endereco; return(cliente); }