Skip to content

DynamicLinq

Stef Heyenrath edited this page Mar 1, 2023 · 10 revisions

Custom DynamicLinq Helpers

These block helpers use System.Linq.Dynamic.Core.


Expression V1

Summary Execute an expression
Returns Result from the expression
Parameters
expression The dynamic expression to execute

Example

Context N/A

Usage

{{Expression '1 + 2'}}

Returns

3

Expression V2

Summary Execute an dynamic expression on an object
Returns Result from the expression
Parameters
object The source object
expression The dynamic expression to execute

Example

Context

{
    "modifyDate": "2012-04-23T18:25:43.511Z"
}

Usage

{{Expression modifyDate 'AddYears(1)'}}

Returns

2013-04-23T18:25:43.511Z

FirstOrDefault

Returns Returns the first element of a sequence, or a default value if no element is found.
Parameters
object The source object
expression The dynamic linq predicate (optional)

Example

Context

{
  "data": [
    "stef",
    "test",
    "other"
  ]
}

Usage

{{DynamicLinq.FirstOrDefault data 'Contains("e")'}}

Returns

"stef"

Where

Returns Filters a sequence of values based on a predicate.
Parameters
object The source object
expression The dynamic linq predicate (optional)

Example

Context

{
  "data": [
    "stef",
    "test",
    "other"
  ]
}

Usage

{{DynamicLinq.Where data 'Contains("e")'}}

Returns

"stef", "test"

Clone this wiki locally