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; }
}
创建一个QuestionId
类的实例,并在Select
内设置QuestionId
属性,方法如下:
Select(m => new QuestionId { QuestionId = m.QuestionId })
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.