我创建了自己的数据库架构来存储用户信息。
CREATE TABLE [dbo].[MyCustomMembership_Users](
[UserId] [uniqueidentifier] NOT NULL,
[UserName] [nvarchar](256) NOT NULL,
[LoweredUserName] [nvarchar](256) NOT NULL,
[MobileAlias] [nvarchar](16) NULL,
[IsAnonymous] [bit] NOT NULL,
[LastActivityDate] [datetime] NOT NULL,
[FirstName] [nvarchar](256) NULL,
[MiddleName] [nvarchar](256) NULL,
[LastName] [nvarchar](256) NULL)
然后我扩展MembershipProvider和MembershipUser并创建overriden方法。 当我调用CreateUser方法时,如何传递附加信息?我知道我可以使用配置文件,但我也希望能够这样做,如果它也是这样的话很复杂,我会去配置文件路线。
public class MyMembershipProvider : MembershipProvider
{
public override MembershipUser CreateUser(string username, string password,
string email, string passwordQuestion, string passwordAnswer, bool isApproved,
object providerUserKey, out MembershipCreateStatus status)
{
throw new NotImplementedException();
}
}
public class MyMembershipUser : MembershipUser
{
private string _firstName;
public string FirstName { get { return _firstName; } set { _firstName = value; } }
private string _middleName;
public string MiddleName { get { return _middleName; } set { _middleName = value; } }
private string _lastName;
public string LastName { get { return _lastName; } set { _lastName = value; } }
public MyMembershipUser() : base()
{
this.FirstName = _firstName;
this.MiddleName = _middleName;
this.LastName = _lastName;
}
}
答案 0 :(得分:0)
您可以在providerUserKey对象中传递MyMembershipUser