开发者

How to create a relationship between ASP.Net MembershipServices user and other tables?

开发者 https://www.devze.com 2022-12-14 10:00 出处:网络
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

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号