1

Lightswitch アプリケーションでは、ユーザーの住所や電話番号などの追加情報を保存する必要があります。これは可能ですか?もしそうなら、どうすればいいですか?

4

1 に答える 1

1

あなたは、Creating a Relationship on current User through SecurityData.UserRegistrations Tableの Richard Waddell の投稿を読みました。

この記事では、lightswitch でユーザー情報を拡張する方法について説明します。

基本的に、プロパティを持つモデルを作成する必要がありusernameます。このプロパティは、lightswitch フォーム ユーザーにバインドされます。マイケルの投稿から:

    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();

        }

    }

現在のユーザー プロファイルを取得するには:

        MyProfile profile = (from persons in          
                             Application.Current.CreateDataWorkspace()
                                    .ApplicationData.MyProfiles
                              where persons.UserName == 
                                    Application.Current.User.Name
                              select persons).FirstOrDefault();
于 2013-01-27T14:20:07.993 に答える