In Entity Framework, we can Eager Load a single row of entity, plus its associated entities, by using Include.
For example, assuming one-to-many relationships between entity A and entities B, C, and D:
var a = context.A
.Where(a => a.Id == 7)
.Include(a => a.B)
.Include(a => a.C)
.Include(a => a.D)
.Single();
However, queries like this can be inefficient. For example in this case, we generate a single SQL query that returns a join of A with B, C, and D. The width of the result rows is therefore approximately equal to the combined widths of the four tables. If all the entries have about the same number of columns, the query will return a payload that is about four times bigger than it has to be. If we query to deeper levels, the SQL generated can get even less efficient.
To improve efficiency, we can use Explicit Loading, with the Load() method. For example,
var a = context.A
.Where(a => a.Id == 7)
.Single();
var b = context.Entry(a).Collection(a => a.B).Load().ToList();
var c = context.Entry(a).Collection(a => a.C).Load().ToList();
var d = context.Entry(a).Collection(a => a.D).Load().ToList();
This maps into four separate queries returning the same total number of rows as before, but with one fourth the width.
In Breeze.js, .expand() maps to .Include() on the server. So I use
var query = breeze.EntityQuery
.from("A")
.where("Id", "==", 7)
.expand("B, C, D");
But is there any Breeze.js query that will map into Explicit Loading on the server and result in more efficient queries as in the EF Eager Loading example above? Maybe this can be accomplished using merging, but I'm not sure how to do it.