1

I have the following LINQ:

        var questionIds = _questionsRepository.GetAll()
            .Where(m => m.Problem != null &&
            m.Problem.SubTopic != null &&
            m.Problem.SubTopic.Topic != null &&
            m.Problem.SubTopic.Topic.SubjectId == 1)
            .Select(m => m.QuestionId)
            .ToList();

Currently it does a select and returns a list of questionIds.

How can I change this LINQ so it returns a List

public class QuestionId
{
    public int QuestionId { get; set; }
}
4

1 回答 1

6

创建一个QuestionId类的实例并在其中设置QuestionId属性Select

Select(m => new QuestionId { QuestionId = m.QuestionId })
于 2013-09-02T15:59:34.850 回答