Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public IEnumerable<Cliente> BuscarClientes()
{
var query = "SELECT TOP 100000 * FROM Cliente";
var lstCliente = new List<Cliente>(100000);
var cmd = new SqlCommand(query, _connection);
using (var reader = cmd.ExecuteReader())
{
if (reader.HasRows)
{
while (reader.Read())
lstCliente.Add(new Cliente
{
Id = (int)reader["Id"],
Nome = reader["Nome"].ToString(),
DataNascimento = (DateTime)reader["DataNascimento"],
ClienteEspecial = (bool)reader["ClienteEspecial"],
NomeDaMae = reader["NomeDaMae"].ToString(),
QuantidadeFilhos = (byte)reader["QuantidadeFilhos"]
});
}
}
return lstCliente;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment