想要在一个视图中使用两个模型。我有两个控制器,一个为当前用户asp.net mvc 3 razor一个视图中的两个控制器
public class ProfileModel
{
public int ID { get; set; }
public decimal Balance { get; set; }
public decimal RankNumber { get; set; }
public decimal RankID { get; set; }
public string PorfileImgUrl { get; set; }
public string Username { get; set; }
}
和第二的firends
public class FriendsModel
{
public int ID { get; set; }
public string Name { get; set; }
public string ProfilePictureUrl { get; set; }
public string RankName { get; set; }
public decimal RankNumber { get; set; }
}
剖面模型总是包含一个项目和朋友模型包含列表
我已经包含两种型号新型号:
public class FullProfileModel
{
public ProfileModel ProfileModel { get; set; }
public FriendsModel FriendModel { get; set; }
}
我试图填充这样FullProfile模型
List<FriendsModel> fmList = GetFriendsData(_UserID);
FullProfileModel fullModel = new FullProfileModel();
fullModel.ProfileModel = pm;
fullModel.FriendModel = fmList.ToList();
但视觉工作室给出.ToList()错误
错误:
Cannot implicitly convert type 'System.Collections.Generic.List<NGGmvc.Models.FriendsModel>' to 'NGGmvc.Models.FriendsModel'
请咨询我的东西我怎么能在单个视图中显示两个型号。
p.s.即时通讯使用MVC3 Razor视图引擎
感谢