OlimilOops
OlimilOops

Reputation: 6797

How to store additional user info

In my Lightswitch application I must store additional informations like address and phone numbers for the users. is this possible, and if so, how to do this?

Upvotes: 1

Views: 899

Answers (1)

dani herrera
dani herrera

Reputation: 51665

You your read Creating a Relationship on current User through SecurityData.UserRegistrations Table Richard Waddell 's post.

This article explains how to extend user info in lightswitch.

Basicaly you should create a model with a username property. This property is binded to lightswitch form users. From Michael's post:

    partial void MyProfiles_Inserting(MyProfile entity)

    {

        var reg = (from regs in 
                      this.DataWorkspace.SecurityData.UserRegistrations
                   where regs.UserName == entity.UserName
                   select regs).FirstOrDefault();

        if (reg == null)

        {

            var newUser = this.DataWorkspace.SecurityData
                              .UserRegistrations.AddNew();
            newUser.UserName = entity.UserName;
            newUser.FullName = entity.Name;
            newUser.Password = "changeme/123";
            this.DataWorkspace.SecurityData.SaveChanges();

        }

    }

To get current user profile:

        MyProfile profile = (from persons in          
                             Application.Current.CreateDataWorkspace()
                                    .ApplicationData.MyProfiles
                              where persons.UserName == 
                                    Application.Current.User.Name
                              select persons).FirstOrDefault();

Upvotes: 1

Related Questions