You are currently browsing legacy 3.5 version of documentation. Click here to switch to the newest 5.1 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Nesting transformers

When you have more complex transformations and you do not want to repeat the code in each transformer to do the exact same transformation, you can use transformer nesting feature by invoking the TransfromWith in your projection function.

public class Orders_Employees_FirstAndLastName : AbstractTransformerCreationTask<Order>
	public class Result
		public string FirstName { get; set; }

		public string LastName { get; set; }

	public Orders_Employees_FirstAndLastName()
		TransformResults =
			orders =>
			from order in orders
			let employee = LoadDocument<Employee>(order.Employee)
			select TransformWith("Employees/FirstAndLastName", employee);

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