How does LINQ expression syntax work with Include() for eager loading
Solution 1:
I figured it out, thanks for the suggestions anyway. The solution is to do this (2nd attempt in my question):
var qry = (from a in Actions
join u in Users on a.UserId equals u.UserId
select a).Include("User")
The reason intellisense didn't show Include after the query was because I needed the following using:
using System.Data.Entity;
Everything worked fine doing this.
Solution 2:
Better, refactor friendly code (EF6)
using System.Data.Entity;
[...]
var x = (from cart in context.ShoppingCarts
where table.id == 123
select cart).Include(t => t.CartItems);
or
var x = from cart in context.ShoppingCarts.Include(nameof(ShoppingCart.CartItems))
where table.id == 123
select cart;
Update 3/31/2017
You can also use include in lambda syntax for either method:
var x = from cart in context.ShoppingCarts.Include(p => p.ShoppingCart.CartItems))
where table.id == 123
select cart;