You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Commands: Transformers: Put

PutTransformer is used to add a transformer to a database.

Syntax

string PutTransformer(string name, TransformerDefinition transformerDef);

Parameters
name string name of a transformer
transformerDef TransformerDefinition definition of a transformer
Return Value
string Transformer name.

Example

string transformerName = store
	.DatabaseCommands
	.PutTransformer(
		"Order/Statistics",
		new TransformerDefinition
		{
			TransformResults = @"from order in results
								select new
								{
									order.OrderedAt,
									order.Status,
									order.CustomerId,
									CustomerName = LoadDocument(order.CustomerId).Name,
									LinesCount = order.Lines.Count
								}",
                        Name = "Order/Statistics"
		});