Last active
July 24, 2018 00:25
-
-
Save vmussak/0d2417a578d55583157d957abd9ff7b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<Cliente> BuscarClientes2() | |
{ | |
var query = "SELECT TOP 100000 * FROM Cliente"; | |
var lstCliente = new List<Cliente>(100000); | |
_connection.Open(); | |
var cmd = new SqlCommand(query, _connection); | |
using (var reader = cmd.ExecuteReader()) | |
{ | |
if (reader.HasRows) | |
{ | |
int id = reader.GetOrdinal("Id"), | |
nome = reader.GetOrdinal("Nome"), | |
dataNascimento = reader.GetOrdinal("DataNascimento"), | |
clienteEspecial = reader.GetOrdinal("ClienteEspecial"), | |
nomeDaMae = reader.GetOrdinal("NomeDaMae"), | |
quantidadeFilhos = reader.GetOrdinal("QuantidadeFilhos"); | |
while (reader.Read()) | |
lstCliente.Add(new Cliente | |
{ | |
Id = reader.GetInt32(id), | |
Nome = reader.GetString(nome), | |
DataNascimento = reader.GetDateTime(dataNascimento), | |
ClienteEspecial = reader.GetBoolean(clienteEspecial), | |
NomeDaMae = reader.GetString(nomeDaMae), | |
QuantidadeFilhos = reader.GetByte(quantidadeFilhos) | |
}); | |
} | |
} | |
return lstCliente; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment