Hi folks,
I have a two classes:
public class Question
{
public IList<Answer> Answers { get; set; }
}
public class Answer
{ .. }
In my Linq2Sql designer, there's two L2S objects on designer, with the correct 0<->many arrow between them. Kewl.
I'm not sure how i can retrieve these questions/answers in a single call and populate my POCO objects ..
this is what i've got ... can someone fill in the blanks?
public IQueryable<Question> GetQuestions()
{
return from q in _db.Questions
select new Question
{
Title = q.Title,
Answers = ???????? // <-- HALP! :)
};
}
thoughts?
Update : War of the POCO
Thanks for the replies but it's not 100% there yet.
Firstly, i'm returning a POCO class, not the Linq2Sql context class. This is why i'm doing...
select new Question { .. };
that class is POCO, not the linq2sql.
Secondly, I like the answers that point to doing Answers = q.Answers.ToList() but this also will not work because it's trying to set a Linq2Sql class to a POCO class.