I am using MembershipServices. I have some othe开发者_如何学编程r tables that I need to associate the records to the user. I created a relationship between aspnet_Users.UserId and MyTable.UserId which are both 'uniqueidentifier' in SQL.
The problem comes when I want to save or lookup a record by user. I am using
customization.UserId = Membership.GetUser().ProviderUserKey;
But it reports a compilation error that you can't convert this to a Guid. I am not sure ProviderUserKey correlates.
How do I create this relationship successfully and reference it programatically?
Just directly cast its type, everything will be OK:
object key = Membership.GetUser().ProviderUserKey;
customization.UserId = (Guid)key;
精彩评论