Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Silverlight业务应用程序中与用户连接其他型号_C#_.net_Visual Studio_Silverlight - Fatal编程技术网

C# 在Silverlight业务应用程序中与用户连接其他型号

C# 在Silverlight业务应用程序中与用户连接其他型号,c#,.net,visual-studio,silverlight,C#,.net,Visual Studio,Silverlight,我真的很难做我需要做的事。 事情是这样的: 我正在创建Silverlight业务应用程序。我希望用户能够定义自己的提醒和模板。它看起来很简单,只有3个模型,2个一对多关系,仅此而已。但我不知道如何将现有的用户模型连接到其他模型 我尝试创建自己的成员资格提供程序-我用所有3个模型创建了db,看起来还可以,我创建了EntityModel,但现在我有两个不同的位置定义了用户类,第一个位置继承了UserBase类,另一个位置继承了自动生成的文件Model.Designer.cs中的EntityObjec

我真的很难做我需要做的事。 事情是这样的:

我正在创建Silverlight业务应用程序。我希望用户能够定义自己的提醒和模板。它看起来很简单,只有3个模型,2个一对多关系,仅此而已。但我不知道如何将现有的用户模型连接到其他模型

我尝试创建自己的成员资格提供程序-我用所有3个模型创建了db,看起来还可以,我创建了EntityModel,但现在我有两个不同的位置定义了用户类,第一个位置继承了UserBase类,另一个位置继承了自动生成的文件Model.Designer.cs中的EntityObject


我完全糊涂了——我能坚持使用EntityObject解决方案,删除类的其他定义吗?如果是这样,我如何仍然能够使用silverlight business application附带的所有功能?已经提供了身份验证/注册等功能。

我们已经在LOB应用程序中实现了此方案

首先,像这样向用户类添加适当的属性

public partial class User : UserBase
{
    public Guid UserId { get; set; }
    public int PeopleId { get; set; }
    public int EpothecaryUserId { get; set; }
    public string PersonFullName { get; set; }
    public SearchGroups SearchGroups { get; set; }
    public string SearchHistoryString { get; set; }
    public int SearchRowsReturnedPerGroup { get; set; }
}
然后创建一个从AuthenticationBase派生的类

public class AuthenticationService : AuthenticationBase<User>
{

    protected override User GetAuthenticatedUser(IPrincipal principal)
    {
        return base.GetAuthenticatedUser(principal).WithProfile();
    }

    [Invoke]
    public void SaveMyUser(User user)
    {
        if (user.UserId == Guid.Empty)
        {
            ClientLogger.Error("SaveMyUser failed because the UserId is invalid");
            return;                
        }

        using (var db = new Pharma360Model())
        {
            var userProfile = db.UserProfiles.Single(p => p.EpothecaryUserId == user.EpothecaryUserId);
            userProfile.SearchGroups = (int)user.SearchGroups;
            userProfile.SearchHistory = user.SearchHistoryString;
            userProfile.SearchRowsReturnedPerGroup = user.SearchRowsReturnedPerGroup;
            db.SaveChanges();
        }
    }
}

这将负责加载和保存自定义用户类