EF4 Code First 绑定到成员角色的用户

发布于 2024-10-07 09:55:25 字数 533 浏览 2 评论 0原文

首先使用代码,并希望跟踪与某些项目相关的用户状态。举个例子,假设我有

public class Currency
{ 
    public decimal Value {get;set;}
    public string OldDude {get;set;}
}

public class UsersCurrencyAmount
{
    virtual public Currency {get;set;} //type of currency in my man-purse
    int quantity {get;set;}
    //how do I refer to MembershipUser here?
}

Do I use MembershipUser direct through some magic, or do I make some like a

public class User
{
    int UserId {get;}
    string UserName {get;}
}

Playing with code first, and want to keep track of a user's state related to certain items. To contrive an example, let's say I've got

public class Currency
{ 
    public decimal Value {get;set;}
    public string OldDude {get;set;}
}

public class UsersCurrencyAmount
{
    virtual public Currency {get;set;} //type of currency in my man-purse
    int quantity {get;set;}
    //how do I refer to MembershipUser here?
}

Do I use MembershipUser directly through some magic, or do I make something like a

public class User
{
    int UserId {get;}
    string UserName {get;}
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

话少情深 2024-10-14 09:55:25

您不应创建从域模型到 .NET 成员资格的依赖关系。您的域中应该有一个 User 类。在应用程序的更高级别,您可以使用成员资格模型(很可能通过抽象)来实现授权需求。

You shouldn't create a dependency from your domain model to the .NET Membership. You should have a User class in your domain. At a higher level in your application you could use the membership model (most likely through an abstraction) to implement authorization needs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文