none
return child objects in linq query RRS feed

  • Question

  •  I have this object questionEntity and it has questionCategory as a child object that is linked based on the QuestionID that i will have when using this query, is there a way i can incorporate returning the proper instance of the question category child object in this query?

                Entities.QuestionsEntity questionEntity = (from q in meta.Questions
                                                        where q.Question == questionText
                                                        select q)
                                                  .IncludeFields(f => f.AuthorId, f => f.Question, f => f.QuestionId, f => f.Answer)
                                                  .FirstOrDefault();
    

    Give youself a round of applause!!
    Thursday, November 5, 2009 4:47 PM

Answers

  • Hello,

    Try this link here: http://freekleemhuis.com/2008/03/12/deferred-loading-with-linq-to-sql/

    it has a good example of deferred loading which I believe fits well to your question!

    Hope this helps!
    • Marked as answer by Yichun_Feng Thursday, November 12, 2009 2:24 AM
    Thursday, November 5, 2009 4:54 PM