# System.Linq.Dynamic.Core

**Kind:** Service

**Source:** `Pams/Core/Pams.Core/Pams.Core.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`System.Linq.Dynamic.Core` is a NuGet package dependency referenced by `Pams.Core.csproj`. It enables .NET code to apply LINQ filtering, sorting, and projection from string expressions, such as query criteria received by a backend endpoint.

## Diagram

```mermaid
sequenceDiagram
    participant Client
    participant Api as Pams API
    participant Core as Pams.Core
    participant DynamicLinq as System.Linq.Dynamic.Core
    participant Data as Data Source

    Client->>Api: Send filter and sort criteria
    Api->>Core: Pass query criteria
    Core->>DynamicLinq: Parse dynamic LINQ expression
    DynamicLinq->>Data: Apply filter and ordering
    Data-->>Core: Return matching records
    Core-->>Api: Return query result
    Api-->>Client: Return response
```

## Usage

```ts
const query = {
  predicate: "Status == @0",
  values: ["Active"],
  orderBy: "CreatedOn descending",
};

const response = await fetch("/api/records/search", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify(query),
});

const records = await response.json();

console.log(records);
```

The backend can pass `predicate`, `values`, and `orderBy` to `System.Linq.Dynamic.Core` when building its LINQ query.

## AI Coding Instructions

- Keep dynamic LINQ expressions in the .NET layer; JavaScript clients should send query criteria rather than execute expressions locally.
- Use parameter placeholders such as `@0` for values instead of concatenating values into expression strings.
- Restrict filterable and sortable property names before passing client input to dynamic LINQ parsing.
- Check `Pams.Core.csproj` before changing package versions or dependency metadata.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Injected or called by (1)

- `Pams.Core` — `Pams/Core/Pams.Core/Pams.Core.csproj`:1
