Skip to content

DynamicLinq

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

Custom DynamicLinq Block Helpers

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


Expression V1

Summary Execute an expression
Returns Result from the expression

||| |Parameters|| |array|Array of objects to make distinct|

Example

Context

{
    "array": [
        "one",
        "two",
        "two",
        "two",
        "three"
    ],
    "badInput": {
        "something": true
    }
}

Usage

<strong>result:</strong>
{{#Enumerable.Distinct array}}
    <strong>True</strong>
    <ul>
    {{#each this}}
        <li>Value: {{this}}</li>
    {{/each}}
    </ul>
{{else}}
    <strong>False</strong>
{{/Distinct}}

{{#Enumerable.Distinct badInput}}
    <strong>True</strong>
    <ul>
    {{#each this}}
        <li>Value: {{this}}</li>
    {{/each}}
    </ul>
{{else}}
    <strong>False</strong>
{{/Distinct}}

Returns

<strong>result:</strong>
<strong>True</strong>
<ul>
    <li>Value: one</li>
    <li>Value: two</li>
    <li>Value: three</li>
</ul>

<strong>False</strong>

IsFirst

Summary Determine whether or not the object passed in is the first element in the passed in array
Returns Whether or not the object is the first element in the array
Remarks
Parameters
array Array of objects to inspect
object Object to match on

Clone this wiki locally