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
Post a Comment