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;}
}
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.
精彩评论