SQL 成员资格提供程序中的 MembershipUser 和 aspnet_User

发布于 2025-01-07 06:41:59 字数 307 浏览 1 评论 0原文

我为 WCF 服务设置了 SQL 成员资格提供程序。

我有自定义表 Items,它有一个外键,将其链接到从会员资格提供程序创建的数据库中的 aspnet_Users 表。当我实例化 aspnet_User 类型的对象时,我可以将项目集合作为用户对象的属性进行访问。但会员资格提供程序仅适用于 MembershipUser 类。

据我所知,aspnet_User 和 MembershipUser 以某种方式链接在一起。当我尝试从 MembershipUser 访问 Items 集合时,这是不可能的,因为没有这样的属性。

您认为我如何访问我的物品收藏?

I set up the SQL Membership provider for my WCF service.

I have custom table Items which has a foreign key that links it to the aspnet_Users table in the db which was created from the Membership provider. When I instantiate an object from type aspnet_User I can access the collection of Items as a attribute to the User obejct. But the membership provider works only with MembershipUser class.

From what I realize the aspnet_User and MembershipUser are somehow linked. When I try to access the Items collection from the MembershipUser it's not possible because there isn't an attribute like that.

How do you think I can access my Items collection?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜扑 2025-01-14 06:41:59

如果您仔细想想,Linq 2 SQL 对 ASP.NET 成员资格一无所知。那么为什么您期望两个系统之间进行合作呢?这将是神奇的。

答:您可以使用 (Guid)MembershipUser.ProviderUserKey 来获取用户的 ID。使用该 ID,您可以查询数据库。

If you think about it, Linq 2 SQL does not know anything about ASP.NET Membership. So why would you expect cooperation between the two systems? This would be magic.

Answer: You can use (Guid)MembershipUser.ProviderUserKey to get the ID of the user. Using that ID you can query the database.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文