public IEnumerable <Cidade> All() { using (NpgsqlCommand cmd = _conexion.Get().CreateCommand()) { string query = "SELECT id, nome, estado_id, cep"; query += " FROM cidade ORDER BY nome"; cmd.CommandType = CommandType.Text; cmd.CommandText = query; using (NpgsqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { yield return(new Cidade() { id = reader.GetInt32(0), nome = reader.IsDBNull(1) == false?reader.GetString(1).ToString() : "", estado_id = reader.GetInt32(2), cep = reader.IsDBNull(3) == false?reader.GetString(3).ToString() : "", }); } } } } }
public IEnumerable <MaeAluno> All() { using (NpgsqlCommand cmd = _conexion.Get().CreateCommand()) { string query = "SELECT id, nome, rg, cpf, profissao, celular, data_cadastro"; query += " FROM mae_aluno ORDER BY nome"; cmd.CommandType = CommandType.Text; cmd.CommandText = query; using (NpgsqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { yield return(new MaeAluno() { id = reader.GetInt32(0), nome = reader.IsDBNull(1) == false?reader.GetString(1).ToString() : "", rg = reader.IsDBNull(2) == false?reader.GetString(2).ToString() : "", cpf = reader.IsDBNull(3) == false?reader.GetString(3).ToString() : "", profissao = reader.IsDBNull(4) == false?reader.GetString(4).ToString() : "", celular = reader.IsDBNull(5) == false?reader.GetString(5).ToString() : "", data_cadastro = reader.IsDBNull(6) == false?DateTime.Parse(reader.GetDateTime(6).ToString()) : DateTime.MinValue, }); } } } } }
public IEnumerable <EnderecoAluno> All() { using (NpgsqlCommand cmd = _conexion.Get().CreateCommand()) { string query = "id, estado_id, cidade_id, bairro_id, rua, rua_nro, cep, aluno_codigo"; query += " FROM endereco_aluno ORDER BY id"; cmd.CommandType = CommandType.Text; cmd.CommandText = query; using (NpgsqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { yield return(new EnderecoAluno() { id = reader.GetInt32(0), estado_id = reader.GetInt32(1), cidade_id = reader.GetInt32(2), bairro_id = reader.GetInt32(3), rua = reader.IsDBNull(4) == false?reader.GetString(4).ToString() : "", rua_nro = reader.IsDBNull(5) == false?reader.GetString(5).ToString() : "", cep = reader.IsDBNull(6) == false?reader.GetString(6).ToString() : "", aluno_codigo = reader.GetInt32(7), }); } } } } }
public IEnumerable <Usuario> All() { using (NpgsqlCommand cmd = _conexion.Get().CreateCommand()) { string query = "SELECT codigo, nome, cpf, sexo, telefone, data_cadastro, cidade_id,"; query += "email, senha FROM usuario ORDER BY nome"; cmd.CommandType = CommandType.Text; cmd.CommandText = query; using (NpgsqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { yield return(new Usuario() { codigo = reader.GetInt32(0), nome = reader.IsDBNull(1) == false?reader.GetString(1).ToString() : "", cpf = reader.IsDBNull(2) == false?reader.GetString(2).ToString() : "", sexo = reader.IsDBNull(3) == false?reader.GetString(3).ToString() : "", telefone = reader.IsDBNull(4) == false?reader.GetString(4).ToString() : "", data_cadastro = reader.IsDBNull(6) == false?DateTime.Parse(reader.GetDateTime(6).ToString()) : DateTime.MinValue, cidade_id = reader.GetInt32(0), email = reader.IsDBNull(7) == false?reader.GetString(7).ToString() : "", senha = reader.IsDBNull(8) == false?reader.GetString(8).ToString() : "", }); } } } } }
public IEnumerable <Aluno> All() { using (NpgsqlCommand cmd = _conexion.Get().CreateCommand()) { string query = "codigo, nome, rg, cpf, data_nacimento, endereco_id, matricula, "; query += "idade, sexo, email, telefone, data_cadastro, pai_id, mae_id"; query += " FROM aluno ORDER BY id"; cmd.CommandType = CommandType.Text; cmd.CommandText = query; using (NpgsqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { yield return(new Aluno() { codigo = reader.GetInt32(0), nome = reader.IsDBNull(1) == false?reader.GetString(1).ToString() : "", rg = reader.IsDBNull(2) == false?reader.GetString(2).ToString() : "", cpf = reader.IsDBNull(3) == false?reader.GetString(3).ToString() : "", data_nacimento = reader.IsDBNull(4) == false?DateTime.Parse(reader.GetDateTime(4).ToString()) : DateTime.MinValue, endereco_id = reader.GetInt32(5), matricula = reader.IsDBNull(6) == false?reader.GetString(6).ToString() : "", idade = reader.GetInt32(7), sexo = reader.IsDBNull(8) == false?reader.GetString(8).ToString() : "", email = reader.IsDBNull(9) == false?reader.GetString(9).ToString() : "", telefone = reader.IsDBNull(10) == false?reader.GetString(10).ToString() : "", data_cadastro = reader.IsDBNull(11) == false?DateTime.Parse(reader.GetDateTime(11).ToString()) : DateTime.MinValue, pai_id = reader.GetInt32(12), mae_id = reader.GetInt32(13), }); } } } } }