Getnews returns an IEnumerable<News> (i.e., several news items), and you are trying to assign it to News news (i.e. one news item). This does not work.
There are two possibilities, depending on what you want to do.
If you want to use all the news, change News news to IEnumerable<News> :
IEnumerable<News> news = newsService.Getnews(GroupID);
If you want to use only one news item, use FirstOrDefault :
News news = newsService.Getnews(GroupID).FirstOrDefault();
Depending on what you expect, you can also use one of the following values:
First() : you expect Getnews always return at least one Getnews news. This will throw an exception if the news is not returned.Single() : You expect Getnews always return exactly one Getnews news. This will throw an exception if more than one or zero news is returned.SingleOrDefault() : You expect zero or one message to be returned. This will throw an exception if multiple news items are returned.
Daniel Hilgarth
source share