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?
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.SqlClientwhen 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.MySqlClienthas abugwhere it will begin to produce failed joins after two projections. This bug was posted to Oracle, but never fixed.