コード例 #1
0
        public static ERUser Get(string username)
        {
            ERUser result = null;

            MySqlConnection conn = DB.Connection();

            conn.Open();

            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = $"SELECT id, username FROM users WHERE username = @Username;";

            MySqlParameter nameParam = new MySqlParameter();

            nameParam.ParameterName = "@Username";
            nameParam.Value         = username;
            cmd.Parameters.Add(nameParam);

            MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                int    newID       = rdr.GetInt32(0);
                string newUsername = rdr.GetString(1);

                result = new ERUser(newUsername, newID);
            }

            DB.Close(conn);

            return(result);
        }
コード例 #2
0
        public static ERUser Get(int id)
        {
            ERUser result = null;

            MySqlConnection conn = DB.Connection();

            conn.Open();

            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = $"SELECT id, username FROM users WHERE id = {id};";

            MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                int    newID    = rdr.GetInt32(0);
                string username = rdr.GetString(1);

                result = new ERUser(username, newID);
            }

            DB.Close(conn);

            return(result);
        }
コード例 #3
0
ファイル: Post.cs プロジェクト: gold-mir/EpicReddit
 public ERUser GetUser()
 {
     AssertIsSaved();
     return(ERUser.Get(_userID));
 }
コード例 #4
0
ファイル: Comment.cs プロジェクト: gold-mir/EpicReddit
 public ERUser GetUser()
 {
     return(ERUser.Get(_userID));
 }