有人可以帮忙吗不确定我在使用什么错误:
在我的控制器中:
[HttpPost]
public ActionResult SaveRecommendedUserDetails(RecommendAFriendViewModel model)
{
//List<Entities.Group.Group> entityGroups = new List<Entities.Group.Group>();
foreach (var group in model.Groups)
{
Entities.Group.Group entityGroup = new Entities.Group.Group();
entityGroup.GroupId = group.GroupId;
//entityGroups.Add(entityGroup);
recommendedUser.Groups.Add(entityGroup); //groups in recommendeduser is already of type ICollection.
}
}
RecommendAFriendViewModel 模型组属性:
public IEnumerable<DataModels.Group.GroupDataModel> Groups { get; set; }
推荐用户实体组属性:
public virtual ICollection<Group.Group> Groups { get; set; }
在我得到的两条红线上:无法从“int”转换为“Zinc.Entities.Group.Group”
和:system.Collections.Generic.List.Add(Zinc.Entities.Group.Group) 的最佳重载方法匹配' 有一些无效的参数
可以告诉我我做错了什么吗?谢谢