EF4 Code First 绑定到成员角色的用户
首先使用代码,并希望跟踪与某些项目相关的用户状态。举个例子,假设我有
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应创建从域模型到 .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.