By default, I have lazy loading enabled on all my models, and that's the way I want to keep things. However, sometimes I want to eagerly fetch all the data up front on an individual query. From everything I've read, I should be using FetchMany() for this purpose. However, if I do:
var dbRecipe = (from r in session.Query<Models.Recipes>().FetchMany(x => x.Ingredients)
where r.RecipeId == recipeId
select r).FirstOrDefault();
Then dbRecipe.Ingredients.Count() returns 1. In other words, it only returns the first ingredient of that recipe. However, if I do:
var dbRecipe = (from r in session.Query<Models.Recipes>()
where r.RecipeId == recipeId
select r).FirstOrDefault();
Then dbRecipe.Ingredients.Count() returns 12, which is correct, however it performs a second query to load the ingredients for that recipe.
How do I make FetchMany fetch all 12 records up front? I was assuming that was the difference between Fetch and FetchMany. I'm clearly doing something wrong.