我有一个方法可以获得用户的组ID,然后我想根据用户的组ID获取新闻。
public IEnumerable<News> Getnews(int GroupID)
{
Expression<Func<News, bool>> constraint = null;
constraint = e => e.GroupID.Equals(GroupID);
return newsRepository.GetMany(constraint);
}
我在这里调用上述方法:
News news = newsService.Getnews(GroupID);
以下是错误信息:
无法隐式将类型 '
System.Collections.Generic.IEnumerable<MeetingBoard.Model.News>
' 转换为 'MeetingBoard.Model.News
'。存在显式转换(是否缺少强制转换?)
IEnumerable<News>
不是News
。 - Jodrellvar news = newsService.Getnews(GroupID);
,你就可以避免后来的混淆。 - Jodrell