public User GetByEmail(string email) { var response = new User(); using (SqlConnection conn = new SqlConnection(ConnectionString())) { using (var cmd = new SqlCommand()) { cmd.Connection = conn; cmd.CommandText = _userSql.SqlGetByEmail(); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@Email", GetDbValue(email)); conn.Open(); using (DbDataReader dr = cmd.ExecuteReader()) { if (dr.Read()) { response.Id = Convert.ToInt32(dr["Id"].ToString()); response.Name = dr["Name"].ToString(); response.Email = dr["Email"].ToString(); } } } } return(response); }