0
比方说,我想为我的ASP.NET MVC网站构建一个评论系统。在我的Comment
模型中,我想保留对喜欢或不喜欢某个评论的用户的参考。在MVC模型中引用用户的最佳方式是什么?
我的模型现在的问题是:
public class Comment
{
public int CommentId { get; set; }
public int PostId { get; set; }
public string Body { get; set; }
// Problem lies here
public virtual ICollection<?> LikedUsers { get; set; }
public virtual ICollection<?> DislikedUsers { get; set; }
}
问:
什么是引用这些用户的最佳方式是什么?
东西来我的脑海中:
商店是喜欢用户ID列表/不喜欢,注释为:
public virtual ICollection<int> LikedUserIds { get; set; }
参考这些用户直接但问题在于,我不知道我应该使用哪种类型的我的
ICollection
直接引用MVC中的用户。我想知道ASP.NET身份用户是否具有某种数据类型,所以我可以在这里使用?
在此先感谢您的任何建议。
我明白了,这当然看起来他们应该实施的方式。关于1,我使用Code First方法。在我的模型中有一个'Dictionary <>'可以吗?关于2,那么ASP.NET中的用户没有预定义的数据类型?我为我的帐户管理使用默认的MVC身份系统。 'ApplicationUser'数据类型可以用来引用用户吗? – Sobhan