asp.net membership provider get UserName by UserId
I have seen a lot of question asking about known user name and how to retrieve U开发者_如何学JAVAserId accordingly. How about the other way around?
For some reason I have UserId, but I don't want to include aspnet_User table into my data entities. Is there any way I can retrieve the user name without querying against aspnet_User table?
MembershipUser user = Membership.GetUser();
if (user != null)
string name = user.UserName;
Internally, this will access the ASP.NET user table. There's no way to avoid that.
精彩评论