Table of Contents

Class Prop

Namespace
MongoDB.Entities
Assembly
MongoDB.Entities.dll

This class provides methods to generate property path strings from lambda expression.

public static class Prop
Inheritance
Prop
Inherited Members

Methods

Collection<T>()

Returns the collection/entity name of a given entity type

public static string Collection<T>() where T : IEntity

Returns

string

Type Parameters

T

The type of the entity to get the collection name of

Elements<T>(int, Expression<Func<T, object?>>)

Returns a path with the filtered positional identifier prepended to the property path.

EX: 0, x => x.Rating > a.Rating

EX: 1, x => x.Rating > b.Rating

TIP: Index positions start from '0' which is converted to 'a' and so on.

public static string Elements<T>(int index, Expression<Func<T, object?>> expression)

Parameters

index int

0=a 1=b 2=c 3=d and so on...

expression Expression<Func<T, object>>

x => x.SomeProp

Returns

string

Type Parameters

T

Elements<T>(Expression<Func<T, object?>>)

Returns a path without any filtered positional identifier prepended to it.

EX: b => b.Tags > Tags

public static string Elements<T>(Expression<Func<T, object?>> expression)

Parameters

expression Expression<Func<T, object>>

x => x.SomeProp

Returns

string

Type Parameters

T

Path<T>(Expression<Func<T, object?>>)

Returns the full dotted path for a given expression.

EX: Authors[0].Books[0].Title > Authors.Books.Title

public static string Path<T>(Expression<Func<T, object?>> expression)

Parameters

expression Expression<Func<T, object>>

x => x.SomeList[0].SomeProp

Returns

string

Type Parameters

T

PosAll<T>(Expression<Func<T, object?>>)

Returns a path with the all positional operator $[] for a given expression.

EX: Authors[0].Name > Authors.$[].Name

public static string PosAll<T>(Expression<Func<T, object?>> expression)

Parameters

expression Expression<Func<T, object>>

x => x.SomeList[0].SomeProp

Returns

string

Type Parameters

T

PosFiltered<T>(Expression<Func<T, object?>>)

Returns a path with filtered positional identifiers $[x] for a given expression.

EX: Authors[0].Name > Authors.$[a].Name

EX: Authors[1].Age > Authors.$[b].Age

EX: Authors[2].Books[3].Title > Authors.$[c].Books.$[d].Title

TIP: Index positions start from [0] which is converted to $[a] and so on.

public static string PosFiltered<T>(Expression<Func<T, object?>> expression)

Parameters

expression Expression<Func<T, object>>

x => x.SomeList[0].SomeProp

Returns

string

Type Parameters

T

PosFirst<T>(Expression<Func<T, object?>>)

Returns a path with the first positional operator $ for a given expression.

EX: Authors[0].Name > Authors.$.Name

public static string PosFirst<T>(Expression<Func<T, object?>> expression)

Parameters

expression Expression<Func<T, object>>

x => x.SomeList[0].SomeProp

Returns

string

Type Parameters

T

Property<T>(Expression<Func<T, object?>>)

Returns the name of the property for a given expression.

EX: Authors[0].Books[0].Title > Title

public static string Property<T>(Expression<Func<T, object?>> expression)

Parameters

expression Expression<Func<T, object>>

x => x.SomeList[0].SomeProp

Returns

string

Type Parameters

T