user1134704
user1134704

Reputation: 45

Custom properties with entity framework

I have 3 entites, Test, sections and questions. a test holds many sections, and a section holds many questions.

how do I add a questions property to my Test entity, the property would contain all the questions in all the sections of that test?

Upvotes: 0

Views: 86

Answers (1)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364249

You will add non mapped property:

public IEnumerable<Question> Questions
{
    get 
    {
        return Sections.SelectMany(s => s.Questions);
    }
}

Upvotes: 1

Related Questions