コード例 #1
0
        private MembershipUser GetUserFromReader(MySqlDataReader reader)
        {
            object providerUserKey = reader.GetInt32("userId");
            string username = reader.GetString("name");

            string email = null;
            if (!reader.IsDBNull(reader.GetOrdinal("Email")))
                email = reader.GetString("Email");

            string passwordQuestion = "";
            if (!(reader.GetValue(reader.GetOrdinal("PasswordQuestion")) == DBNull.Value))
                passwordQuestion = reader.GetString("PasswordQuestion");

            string comment = "";
            if (!(reader.GetValue(reader.GetOrdinal("Comment")) == DBNull.Value))
                comment = reader.GetString("Comment");

            bool isApproved = reader.GetBoolean("IsApproved");
            bool isLockedOut = reader.GetBoolean("IsLockedOut");
            DateTime creationDate = reader.GetDateTime("CreationDate");
            DateTime lastLoginDate = new DateTime();
            if (!(reader.GetValue(reader.GetOrdinal("LastLoginDate")) == DBNull.Value))
                lastLoginDate = reader.GetDateTime("LastLoginDate");

            DateTime lastActivityDate = reader.GetDateTime("LastActivityDate");
            DateTime lastPasswordChangedDate = reader.GetDateTime("LastPasswordChangedDate");
            DateTime lastLockedOutDate = new DateTime();
            if (!(reader.GetValue(reader.GetOrdinal("LastLockedoutDate")) == DBNull.Value))
                lastLockedOutDate = reader.GetDateTime("LastLockedoutDate");

            MembershipUser u =
                new MembershipUser(Name, username, providerUserKey, email, passwordQuestion, comment, isApproved,
                                   isLockedOut, creationDate, lastLoginDate, lastActivityDate, lastPasswordChangedDate,
                                   lastLockedOutDate);
            return u;
        }
コード例 #2
0
 private static string GetString(MySqlDataReader reader, int index)
 {
     if (reader.IsDBNull(index))
         return null;
     return reader.GetString(index);
 }