Table of Contents

Class LinqExpressionBuilder

Namespace
Arbiter.CommandQuery.Queries
Assembly
Arbiter.CommandQuery.dll

Builds a string-based LINQ expression from an EntityFilter instance.

public class LinqExpressionBuilder
Inheritance
LinqExpressionBuilder
Inherited Members

Examples

The following example demonstrates how to use LinqExpressionBuilder to build a LINQ expression from an EntityFilter:

// Create a filter for entities where Status == "Active" and Priority > 1
var filter = new EntityFilter
{
    Logic = "and",
    Filters = new List<EntityFilter>
    {
        new EntityFilter { Name = "Status", Operator = "eq", Value = "Active" },
        new EntityFilter { Name = "Priority", Operator = "gt", Value = 1 }
    }
};

// Build the LINQ expression
var builder = new LinqExpressionBuilder();
builder.Build(filter);

// Access the generated expression and parameters
string expression = builder.Expression; // e.g., "(Status == @0 and Priority > @1)"
var parameters = builder.Parameters;    // [ "Active", 1 ]

Remarks

This class converts an EntityFilter (including nested/grouped filters) into a LINQ expression string and a corresponding list of parameter values.

Properties

Expression

Gets the generated LINQ expression string.

public string Expression { get; }

Property Value

string

Parameters

Gets the list of parameter values used in the generated LINQ expression.

public IReadOnlyList<object?> Parameters { get; }

Property Value

IReadOnlyList<object>

Methods

Build(EntityFilter?)

Builds a string-based LINQ expression from the specified EntityFilter.

public void Build(EntityFilter? entityFilter)

Parameters

entityFilter EntityFilter

The entity filter to build the expression from.

Remarks

This method clears any previous expression and parameters before building a new one.