更新与SimpleMembershipProvider自定义用户配置文件字段? [英] Update custom user profile fields with SimpleMembershipProvider?
问题描述
我添加了一个自定义字段名为用户配置
表 ClassOfYear
,我能得到的数据为像这样在注册过程中的配置文件:
I added a custom field to the UserProfile
table named ClassOfYear
and I'm able to get the data into the profile during registration like this:
var confirmationToken = WebSecurity.CreateUserAndAccount(model.UserName,
model.Password,
propertyValues: new { ClassOfYear = model.ClassOfYear },
requireConfirmationToken: true);
不过,现在我希望能够以更新的姿态,当我管理它,但我似乎无法找到一个方法来做到这一点。 我是否需要简单地更新用户配置
表自己?如果没有,是什么这样做的适当方法是什么?
However, now I want to be able to update the profile when I manage it but I can't seem to find a method to do so. Do I need to simply update the UserProfile
table myself? If not, what is the appropriate way of doing this?
通知你,我用精致小巧的我的数据访问层,以防万一它很重要。但是,就像说,我可以更新用户配置
通过小巧精致的表,如果那是我应该做的,我只是想通了 WebSecurity
类,或类似的东西,有办法已自定义用户配置文件字段被集成到 CreateUserAndAccount
方法。
FYI, I'm using Dapper as my data access layer, just in case it matters. But, like stated, I can just update the UserProfile
table via Dapper if that's what I'm supposed to do, I just figured that the WebSecurity
class, or something similar, had a way already since the custom user profile fields are integrated with the CreateUserAndAccount
method.
谢谢大家!
推荐答案
有没有在SimpleMembershipProvider code,做任何额外的领域,除了在创建。
There is nothing in the SimpleMembershipProvider code that does anything with additional fields except upon create.
只需从你的ORM查询自己的价值观。
Simply query the values yourself from your ORM.
您可以使用WebSecurity.GetUserId(User.Identity.Name)来获得用户的ID,然后小巧玲珑查询用户配置表中。
You can use the WebSecurity.GetUserId(User.Identity.Name) to get the user's id and then Dapper to query the UserProfile table.
这篇关于更新与SimpleMembershipProvider自定义用户配置文件字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!