我有以下内容:
public IList<TopicSubTopic> GetTopicSubTopics(int topicId)
{
var topicSubTopics = _subTopicsRepository
.GetAll()
.Where(s => s.TopicId == topicId)
.Include(s => s.Topic)
.ToList();
var topicSubTopicsSelect = from item in topicSubTopics.AsEnumerable()
select new TopicSubTopic(
item.TopicId,
item.SubTopicId,
item.Topic.Name,
item.Name);
return topicSubTopicsSelect;
}
和:
public partial class TopicSubTopic
{
public TopicSubTopic(int topicId, int subTopicId, string topicName, string subTopicName)
{
TopicId = topicId;
SubTopicId = subTopicId;
TopicName = topicName;
SubTopicName = subTopicName;
}
public int TopicId { get; set; }
public int SubTopicId { get; set; }
public string TopicName { get; set; }
public string SubTopicName { get; set; }
}
我的 IDE 给了我以下信息:
Error 3 Cannot implicitly convert type
'System.Collections.Generic.IEnumerable<Models.Views.TopicSubTopic>' to
'System.Collections.Generic.IList<Models.Views.TopicSubTopic>'.
An explicit conversion exists (are you missing a cast?)