Class Template<TInput, TResult>
A helper class to build a JSON command from a string with tag replacement
Inherited Members
Namespace: MongoDB.Entities
Assembly: MongoDB.Entities.dll
Syntax
public class Template<TInput, TResult> : Template where TInput : IEntity
Type Parameters
Name | Description |
---|---|
TInput | The input type |
TResult | The output type |
Constructors
Template(String)
Initializes a template with a tagged input string.
Declaration
public Template(string template)
Parameters
Type | Name | Description |
---|---|---|
String | template | The template string with tags for targeting replacements such as "<Author.Name>" |
Methods
Collection<TEntity>()
Gets the collection name of a given entity type and replaces matching tags in the template such as "<EntityName>"
Declaration
public Template<TInput, TResult> Collection<TEntity>()
where TEntity : IEntity
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Type Parameters
Name | Description |
---|---|
TEntity | The type of entity to get the collection name of |
Elements(Int32, Expression<Func<TInput, Object>>)
Turns the given index and expression (of input type) to a path with the filtered positional identifier prepended to the property path like "a.Name" and replaces matching tags in the template such as "<a.Name>"
Declaration
public Template<TInput, TResult> Elements(int index, Expression<Func<TInput, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | 0=a 1=b 2=c 3=d and so on... |
Expression<Func<TInput, Object>> | expression | x => x.SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Elements(Expression<Func<TInput, Object>>)
Turns the given expression (of input type) to a path without any filtered positional identifier prepended to it like "Name" and replaces matching tags in the template such as "<Name>"
Declaration
public Template<TInput, TResult> Elements(Expression<Func<TInput, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TInput, Object>> | expression | x => x.SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Elements<TOther>(Int32, Expression<Func<TOther, Object>>)
Turns the given index and expression (of any type) to a path with the filtered positional identifier prepended to the property path like "a.Name" and replaces matching tags in the template such as "<a.Name>"
Declaration
public Template<TInput, TResult> Elements<TOther>(int index, Expression<Func<TOther, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | 0=a 1=b 2=c 3=d and so on... |
Expression<Func<TOther, Object>> | expression | x => x.SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Type Parameters
Name | Description |
---|---|
TOther |
Elements<TOther>(Expression<Func<TOther, Object>>)
Turns the given expression (of any type) to a path without any filtered positional identifier prepended to it like "Name" and replaces matching tags in the template such as "<Name>"
Declaration
public Template<TInput, TResult> Elements<TOther>(Expression<Func<TOther, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TOther, Object>> | expression | x => x.SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Type Parameters
Name | Description |
---|---|
TOther |
ElementsOfResult(Int32, Expression<Func<TResult, Object>>)
Turns the given index and expression (of output type) to a path with the filtered positional identifier prepended to the property path like "a.Name" and replaces matching tags in the template such as "<a.Name>"
Declaration
public Template<TInput, TResult> ElementsOfResult(int index, Expression<Func<TResult, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | 0=a 1=b 2=c 3=d and so on... |
Expression<Func<TResult, Object>> | expression | x => x.SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
ElementsOfResult(Expression<Func<TResult, Object>>)
Turns the given expression (of output type) to a path without any filtered positional identifier prepended to it like "Name" and replaces matching tags in the template such as "<Name>"
Declaration
public Template<TInput, TResult> ElementsOfResult(Expression<Func<TResult, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TResult, Object>> | expression | x => x.SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Path(Expression<Func<TInput, Object>>)
Turns the given expression (of input type) to a dotted path like "SomeList.SomeProp" and replaces matching tags in the template such as "<SomeList.SomeProp>"
Declaration
public Template<TInput, TResult> Path(Expression<Func<TInput, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TInput, Object>> | expression | x => x.SomeList[0].SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Path<TOther>(Expression<Func<TOther, Object>>)
Turns the given expression (of any type) to a dotted path like "SomeList.SomeProp" and replaces matching tags in the template such as "<SomeList.SomeProp>"
Declaration
public Template<TInput, TResult> Path<TOther>(Expression<Func<TOther, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TOther, Object>> | expression | x => x.SomeList[0].SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Type Parameters
Name | Description |
---|---|
TOther |
PathOfResult(Expression<Func<TResult, Object>>)
Turns the given expression (of output type) to a dotted path like "SomeList.SomeProp" and replaces matching tags in the template such as "<SomeList.SomeProp>"
Declaration
public Template<TInput, TResult> PathOfResult(Expression<Func<TResult, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TResult, Object>> | expression | x => x.SomeList[0].SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Paths(Expression<Func<TInput, Object>>)
Turns the property paths in the given new
expression (of input type) into paths like "Prop1.Child1 & Prop2.Child2" and replaces matching tags in the template.
Declaration
public Template<TInput, TResult> Paths(Expression<Func<TInput, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TInput, Object>> | expression | x => new { x.Prop1.Child1, x.Prop2.Child2 } |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Paths<TOther>(Expression<Func<TOther, Object>>)
Turns the property paths in the given new
expression (of any type) into paths like "Prop1.Child1 & Prop2.Child2" and replaces matching tags in the template.
Declaration
public Template<TInput, TResult> Paths<TOther>(Expression<Func<TOther, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TOther, Object>> | expression | x => new { x.Prop1.Child1, x.Prop2.Child2 } |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Type Parameters
Name | Description |
---|---|
TOther |
PathsOfResult(Expression<Func<TResult, Object>>)
Turns the property paths in the given new
expression (of output type) into paths like "Prop1.Child1 & Prop2.Child2" and replaces matching tags in the template.
Declaration
public Template<TInput, TResult> PathsOfResult(Expression<Func<TResult, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TResult, Object>> | expression | x => new { x.Prop1.Child1, x.Prop2.Child2 } |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
PosAll(Expression<Func<TInput, Object>>)
Turns the given expression (of input type) to a path with the all positional operator like "Authors.\([].Name" and replaces matching tags in the template such as "<Authors.\)[].Name>"
Declaration
public Template<TInput, TResult> PosAll(Expression<Func<TInput, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TInput, Object>> | expression | x => x.SomeList[0].SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
PosAll<TOther>(Expression<Func<TOther, Object>>)
Turns the given expression (of any type) to a path with the all positional operator like "Authors.\([].Name" and replaces matching tags in the template such as "<Authors.\)[].Name>"
Declaration
public Template<TInput, TResult> PosAll<TOther>(Expression<Func<TOther, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TOther, Object>> | expression | x => x.SomeList[0].SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Type Parameters
Name | Description |
---|---|
TOther |
PosAllOfResult(Expression<Func<TResult, Object>>)
Turns the given expression (of output type) to a path with the all positional operator like "Authors.\([].Name" and replaces matching tags in the template such as "<Authors.\)[].Name>"
Declaration
public Template<TInput, TResult> PosAllOfResult(Expression<Func<TResult, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TResult, Object>> | expression | x => x.SomeList[0].SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
PosFiltered(Expression<Func<TInput, Object>>)
Turns the given expression (of input type) to a positional filtered path like "Authors.\([a].Name" and replaces matching tags in the template such as "<Authors.\)[a].Name>"
TIP: Index positions start from [0] which is converted to $[a] and so on.
Declaration
public Template<TInput, TResult> PosFiltered(Expression<Func<TInput, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TInput, Object>> | expression | x => x.SomeList[0].SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
PosFiltered<TOther>(Expression<Func<TOther, Object>>)
Turns the given expression (of any type) to a positional filtered path like "Authors.\([a].Name" and replaces matching tags in the template such as "<Authors.\)[a].Name>"
TIP: Index positions start from [0] which is converted to $[a] and so on.
Declaration
public Template<TInput, TResult> PosFiltered<TOther>(Expression<Func<TOther, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TOther, Object>> | expression | x => x.SomeList[0].SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Type Parameters
Name | Description |
---|---|
TOther |
PosFilteredOfResult(Expression<Func<TResult, Object>>)
Turns the given expression (of output type) to a positional filtered path like "Authors.\([a].Name" and replaces matching tags in the template such as "<Authors.\)[a].Name>"
TIP: Index positions start from [0] which is converted to $[a] and so on.
Declaration
public Template<TInput, TResult> PosFilteredOfResult(Expression<Func<TResult, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TResult, Object>> | expression | x => x.SomeList[0].SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
PosFirst(Expression<Func<TInput, Object>>)
Turns the given expression (of input type) to a path with the first positional operator like "Authors.\(.Name" and replaces matching tags in the template such as "<Authors.\).Name>"
Declaration
public Template<TInput, TResult> PosFirst(Expression<Func<TInput, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TInput, Object>> | expression | x => x.SomeList[0].SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
PosFirst<TOther>(Expression<Func<TOther, Object>>)
Turns the given expression (of any type) to a path with the first positional operator like "Authors.\(.Name" and replaces matching tags in the template such as "<Authors.\).Name>"
Declaration
public Template<TInput, TResult> PosFirst<TOther>(Expression<Func<TOther, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TOther, Object>> | expression | x => x.SomeList[0].SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Type Parameters
Name | Description |
---|---|
TOther |
PosFirstOfResult(Expression<Func<TResult, Object>>)
Turns the given expression (of output type) to a path with the first positional operator like "Authors.\(.Name" and replaces matching tags in the template such as "<Authors.\).Name>"
Declaration
public Template<TInput, TResult> PosFirstOfResult(Expression<Func<TResult, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TResult, Object>> | expression | x => x.SomeList[0].SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Properties(Expression<Func<TInput, Object>>)
Turns the property paths in the given new
expression (of input type) into names like "PropX & PropY" and replaces matching tags in the template.
Declaration
public Template<TInput, TResult> Properties(Expression<Func<TInput, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TInput, Object>> | expression | x => new { x.Prop1.PropX, x.Prop2.PropY } |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Properties<TOther>(Expression<Func<TOther, Object>>)
Turns the property paths in the given new
expression (of any type) into paths like "PropX & PropY" and replaces matching tags in the template.
Declaration
public Template<TInput, TResult> Properties<TOther>(Expression<Func<TOther, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TOther, Object>> | expression | x => new { x.Prop1.PropX, x.Prop2.PropY } |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Type Parameters
Name | Description |
---|---|
TOther |
PropertiesOfResult(Expression<Func<TResult, Object>>)
Turns the property paths in the given new
expression (of output type) into names like "PropX & PropY" and replaces matching tags in the template.
Declaration
public Template<TInput, TResult> PropertiesOfResult(Expression<Func<TResult, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TResult, Object>> | expression | x => new { x.Prop1.PropX, x.Prop2.PropY } |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Property(Expression<Func<TInput, Object>>)
Turns the given member expression (of input type) into a property name like "SomeProp" and replaces matching tags in the template such as "<SomeProp>"
Declaration
public Template<TInput, TResult> Property(Expression<Func<TInput, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TInput, Object>> | expression | x => x.RootProp.SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Property<TOther>(Expression<Func<TOther, Object>>)
Turns the given member expression (of any type) into a property name like "SomeProp" and replaces matching tags in the template such as "<SomeProp>"
Declaration
public Template<TInput, TResult> Property<TOther>(Expression<Func<TOther, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TOther, Object>> | expression | x => x.RootProp.SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Type Parameters
Name | Description |
---|---|
TOther |
PropertyOfResult(Expression<Func<TResult, Object>>)
Turns the given member expression (of output type) into a property name like "SomeProp" and replaces matching tags in the template such as "<SomeProp>"
Declaration
public Template<TInput, TResult> PropertyOfResult(Expression<Func<TResult, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TResult, Object>> | expression | x => x.RootProp.SomeProp |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
Tag(String, String)
Replaces the given tag in the template like "<search_term>" with the supplied value.
Declaration
public Template<TInput, TResult> Tag(string tagName, string replacementValue)
Parameters
Type | Name | Description |
---|---|---|
String | tagName | The tag name without the surrounding < and > |
String | replacementValue | The value to replace with |
Returns
Type | Description |
---|---|
Template<TInput, TResult> |
ToArrayFilters()
Executes the tag replacement and returns array filter definitions.
TIP: if all the tags don't match, an exception will be thrown.
Declaration
public IEnumerable<ArrayFilterDefinition> ToArrayFilters()
Returns
Type | Description |
---|---|
IEnumerable<ArrayFilterDefinition> |
ToPipeline()
Executes the tag replacement and returns a pipeline definition.
TIP: if all the tags don't match, an exception will be thrown.
Declaration
public PipelineDefinition<TInput, TResult> ToPipeline()
Returns
Type | Description |
---|---|
PipelineDefinition<TInput, TResult> |