I have 3 classes
public class Test
{
private List<Question> _questions;
private string _text;
public string Text
{
get
{
return _text;
}
}
//...
}
public class Question
{
private List<Answer> _answers;
private string _text;
public string Text
{
get
{
return _text;
}
}
//...
}
public class Answer
{
private string _text;
private bool _isCorrect;
public string Text
{
get
{
return _text;
}
}
public bool isCorrect
{
get
{
return _isCorrect;
}
}
//...
}
I need to select a Text from Questions and Text from Answers, where Answer is correct.
I can only select correct Answers.
Test t;
//Initializing t
var r = t.SelectMany<Question, Answer>(q => q).Where<Answer>(a => a.isCorrect == true);
My question is: How to select a Text from Questions and Text from Answers, where Answer is correct. I need to make a linq to objects query.