ilovegame
ilovegame

Reputation: 9

Entityframework single select from nested tables

I have a problem to make a single query that doesn't take all columns from database. Let's say i have schema:

table1 {
    id,
    column1,
    column2,
    column3
}

table2 {
    id,
    table1ID,
    column1,
    column2,
    column3
}
table3 {
    id,
    table2ID,
    column1,
    column2,
    column3
}
...
tableN {
    id,
    table(N-1)ID,
    column1,
    column2,
    column3
}

I'd like to make a linq query to select table1.column1 and all data from table2..tableN structure.

Since I want all fields from table2..tableN I can create DTOs with corresponding fields and use AutoMapper(I don't really see a problem with that, however I've seen some discouragement online).

Solutions I know:

Do you know any better solutions?

Upvotes: 0

Views: 255

Answers (1)

share pvv
share pvv

Reputation: 81

with your database structure. you should create a front view with all the fields(All column of all Table) you want, and then use LINQ query.

Upvotes: 1

Related Questions