An explicit conversion exists (are you missing a cast?)

后端 未结 6 663
礼貌的吻别
礼貌的吻别 2020-12-10 13:06

I have a method that gives me the groupID of users and then I want to get the news based on the user\'s GroupID.

public IEnumerable Getnews(int G         


        
6条回答
  •  北海茫月
    2020-12-10 13:52

    Getnews returns a collection of news items, and your line is expecting a single news item.

    You could try

    News news = newsServices.Getnews(GroupID).FirstOrDefault();
    

    or expect an ineumerable

    IEnumerable news = newsService.GetNews(GroupID);
    

提交回复
热议问题