开发者

How to initialize Profile properties in Silverlight 4 using WCF RIA

I'm using Silverlight 4, C#, WCF RIA services and SQL Server 2008. I've got a table that stores details for users e.g. First name, Last name etc. I have defined a profile in my AuthenticationDomainService's class that inherits from UserBase. It looks like this:

public class BrightSparksUser : UserBase
{
    public string firstName { get; set; }
    public string lastName { get; set; }
    public DateTime dateOfBirth { get; set; }
    public String typeOfIdentification { get; set; }
    public String idNumber { get; set; }
    public String cellNumber { get; set; }
    public String emailAddress { get; set; }
    public int userNumber { get; private set; }
    public int centreOfInstruction { get; set; }
    public int accessLevel { get; set; }
}

I've modified the Web.config file appropriately on the server side. I'm able to store and retrieve data from and in these fields on the client side, so all is set up correctly.

I would like to be able to fill these fields with the details stored in the DataBase when the user logs in. Logging in works fine using a custom MembershipProvider.

public class BrightSparksMembershipProvider : MembershipProvider
{
    public override bool ValidateUser(string usernumber, string password)
    {

        using (BRIGHT_SPARKSEntities context = new BRIGHT_SPARKSEntities())
        {

            var user = context.Users.Where(u => u.Email == usernumber && u.Password == password).FirstOrDefault();
            return user != null;
        }

Is it possible to fill the fields like I explained? How would you go about doing this?

Thanks for the help guys.

PS: This is my first 开发者_如何学Pythonquestion here so please tell me if I'm being too vague or too specific :)


You can callout to your membership class from your service class by doing something like this:

BrightSparksMembershipProvider provider = 
    Membership.Provider as BrightSparksMembershipProvider;
BrightSparksUser user = 
    (BrightSparksUser)provider.GetUser(user.Username);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜