# Read First Record

## Syntax

```
GetFirst(filter, orderBy);
```

## Arguments

<table data-header-hidden><thead><tr><th width="139">Argument</th><th width="225">Data Type</th><th width="290">Description</th><th>Default Value</th></tr></thead><tbody><tr><td><em>filter</em></td><td>Expression&#x3C;Func&#x3C;T, bool>></td><td><p>Criteria by which the records of the repository should be filtered. </p><p>This parameter must not be empty. </p></td><td>null</td></tr><tr><td><p><em>orderBy</em></p><p> </p></td><td>Func&#x3C;IQueryable&#x3C;T>, IOrderedQueryable&#x3C;T>></td><td><p>Order in which the records should be listed. </p><p>This parameter is optional.</p></td><td>null</td></tr></tbody></table>

## Description

Gets the first record from a repository that fulfills the criteria specified in the parameter _filter_.

If _orderBy_ is not null, it first orders the records according to the attributes specified in the parameter _orderBy_ before getting the first record from the newly ordered list.&#x20;

## Example

### Example 1: Filtering records by only one criterion

The following program illustrates the function call with only one criterion:

```
var orderFirst = repo.GetFirst(x => x.ProductID == "ADAM-567-BTO");
```

Function will load the first record from the repository that has "ADAM-567-BTO" as Production ID and store the result into the variable "orderFirst".

### Example 2: Filtering records by multiple criteria

The following program illustrates the function call with multiple criteria:

```
var orderFirst = repo.GetFirst(x => x.ProductID == "ADAM-567-BTO" 
                                 && x.Quantity > 10 
                                 && x.IsUrgent == true);
```

Function will load the first record from the repository that has "ADAM-567-BTO" as Production ID, has a Quantity of more than 10 and is Urgent, and store the result into the variable "orderFirst".

### Example 3: Filtering records by multiple criteria with order

The following program illustrates the function call with multiple criteria and specified order:

```
r orderList = repo.Get(x => x.ProductID == "ADAM-567-BTO" 
                         && x.Quantity > 10, 
                       o => o.OrderBy(c => c.Timestamp);
```

Function will order the records by their Timestamp attribute, load the first record from the ordered repository that has "ADAM-567-BTO" as Production ID and a Quantity of more than 10 and store the result into the variable "orderFirst".

