I am trying the following:
var questions = _questionsRepository
.GetAll()
.Where(q => q.Problem.SubTopicId == subTopicId || subTopicId == 0)
.Where(q => q.QuestionStatusId == questionStatusId || questionStatusId == 0)
.Where(q => q.AssignedTo == assignedTo || assignedTo == "0")
.Where(q => q.ModifiedBy == modifiedBy || modifiedBy == "0")
.Include(q => q.Problem)
.Include(q => q.Answers)
.Select(x=>new Question {
QuestionId = x.QuestionId,
QuestionUId = x.QuestionUId,
Answers = x.Answers,
Problem = new Problem {
ProblemId = x.Problem.ProblemId
}
}).ToList();
But getting an error message saying:
System.NotSupportedException was unhandled by user code
HResult=-2146233067
Message=The entity or complex type 'Models.Contexts.Question' cannot be constructed in a LINQ to Entities query.
Source=EntityFramework
StackTrace: