> ## Documentation Index
> Fetch the complete documentation index at: https://learn.nexudus.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Filtering Records

> How to filter search results by field values using the Nexudus SDK.

# Filtering Records

Pass a `Dictionary<string, string>` of filters to `SearchAsync` to narrow down results. Filter keys follow the pattern **`EntityName_PropertyName`**. Multiple filters are combined with AND logic.

## Filter by text field

```csharp theme={null}
var endpoint = new CoworkerEndpoint(client);

var filters = new Dictionary<string, string>
{
    ["Coworker_FullName"] = "Jane"
};

SearchResult<Coworker> result = await endpoint.SearchAsync(filters);
```

## Filter by email

```csharp theme={null}
var filters = new Dictionary<string, string>
{
    ["Coworker_Email"] = "jane@example.com"
};
var result = await endpoint.SearchAsync(filters);
```

## Filter by enum

Pass the integer value of the enum member:

```csharp theme={null}
var filters = new Dictionary<string, string>
{
    ["Coworker_CoworkerType"] = "1" // Individual
};
var result = await endpoint.SearchAsync(filters);
```

## Filter by foreign key ID

```csharp theme={null}
var filters = new Dictionary<string, string>
{
    ["Booking_Resource"] = "98765"
};
var result = await new BookingEndpoint(client).SearchAsync(filters);
```

## Filter by related entity property

Use dot-separated paths to filter on properties of related entities:

```csharp theme={null}
var filters = new Dictionary<string, string>
{
    ["Booking_Resource_Name"] = "Meeting Room A"
};
var result = await new BookingEndpoint(client).SearchAsync(filters);
```

## Combine multiple filters

All filters are ANDed together. You can also combine filtering with pagination:

```csharp theme={null}
var filters = new Dictionary<string, string>
{
    ["Coworker_CoworkerType"] = "1",
    ["Coworker_CompanyName"] = "Acme"
};

var result = await endpoint.SearchAsync(filters, page: 2, size: 5);
```

## Sorting results

In addition to filtering, you can control the sort order by passing `orderBy` and `dir` to `SearchAsync`:

```csharp theme={null}
var filters = new Dictionary<string, string>
{
    ["Coworker_CompanyName"] = "Acme"
};

// Filter by company AND sort by FullName descending
var result = await endpoint.SearchAsync(filters, page: 1, size: 25, orderBy: "FullName", dir: 1);
```

| Parameter | Type     | Values                                       |
| --------- | -------- | -------------------------------------------- |
| `orderBy` | `string` | Any property name on the entity.             |
| `dir`     | `int`    | `0` = ascending (default), `1` = descending. |

If `orderBy` is not specified, the API uses the entity's default sort property.

## Filter key reference

| Pattern                      | Example                 | Description                          |
| ---------------------------- | ----------------------- | ------------------------------------ |
| `Entity_Property`            | `Coworker_FullName`     | Direct property on the entity.       |
| `Entity_Property` (enum)     | `Coworker_CoworkerType` | Enum field — pass the integer value. |
| `Entity_ForeignKey`          | `Booking_Resource`      | Foreign key — pass the related ID.   |
| `Entity_ForeignKey_Property` | `Booking_Resource_Name` | Property on a related entity.        |
