1

How many nested projections can be used with .Include() in the Entity Framework?

For example:

Class A has a List of Class B's, which has a list of Class C's, which has a list of Class D's, etc.

query.Include( a => a.BList.Select( b => b.Clist.Select( c => c.DList.Select(...) ) ) );

How far can these go?

4

2 回答 2

1

They can go as far as you want. There is no programmatic limit, but I'm sure you would deplete some resource after a ridiculous amount of inclusions.

于 2012-07-27T21:18:23.383 回答
1

MSSQL - As Many as you want

You can have as many nested projections as you wish when using Entity Framework with a MSSQL database. The query is formed by the System.Data.SqlClient when using MSSQL.


MySQL - Only 2

However, you can only use 2 projections before you begin to receive logical errors when using Entity Framework with MySQL. The MySql provider MySql.Data.MySqlClient has a bug where it will begin to produce failed joins after two projections. This bug was posted to Oracle, but never fixed.

于 2012-07-27T21:23:46.283 回答