Loading documents

Sometimes, in our results set, we want to include data from referenced documents. To do so, the ability to load external documents was introduced. To use it just invoke the LoadDocument method with appropriate parameters. This method contains various overloads that can be used to load a single document by its Id or to load multiple documents from an array containing Ids:

public class Products_ProductAndCategoryName : AbstractTransformerCreationTask<Product>
	public class Result
		public string ProductName { get; set; }

		public string CategoryName { get; set; }

	public Products_ProductAndCategoryName()
		TransformResults =
			products =>
			from product in products
			let category = LoadDocument<Category>(product.Category)
			select new
				ProductName = product.Name,
				CategoryName = category.Name

IList<Products_ProductAndCategoryName.Result> results = session
	.Where(x => x.Name == "Chocolade")
	.TransformWith<Products_ProductAndCategoryName, Products_ProductAndCategoryName.Result>()