c# - getting most inner type object in one to many relation in linq -


i'm new linq.i have 3 entities in db

 type, question,answer 

every type have many questions every question have many answers, eagerly loaded ilist, have question , answers, need fetch of answers disregard type , question, mean need have result type type of answer have of answers in db. have

ilist<type> types=context.types.tolist(); 

but dont have idea how answers.

include "question" , "question.answer" provide list foreign key relationship.

ilist<type> types = context.types.include("question").include("question.answer").tolist(); 

to check

var questions = types.selectmany(t => t.question).tolist(); var answers = questionlist.selectmany(t => t.answer).tolist(); 

but think should directly.

ilist<question> questions = context.question.include("type").include("answer").tolist(); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -