# Generate Row-Id

## Syntax

```
NewID(filter, len, prefix);
```

## Arguments

<table data-header-hidden><thead><tr><th width="181">Argument</th><th width="189">Data Type</th><th width="272">Description</th><th>Default Value</th></tr></thead><tbody><tr><td><em>filter</em></td><td>Expression&#x3C;Func&#x3C;T, string>></td><td><p>Column that contains the ID (Primary Key). </p><p>This parameter must not be empty.</p></td><td>null </td></tr><tr><td><em>len</em></td><td>int</td><td>Total number of characters ID should consist of (including <em>prefix</em>).</td><td>8</td></tr><tr><td><em>prefix</em></td><td>string</td><td></td><td>null</td></tr></tbody></table>

## Description

Generates a new ID value for the Primary Key column that is specified in the parameter _filter_ by taking the ID value of the newest record in the repository and incrementing it by 1.&#x20;

If parameter _len_ is specified, it will additionally add preceding zeroes until the number of digits/characters equals the number specified in the parameter _len_. If _len_ is not specified, it will add preceding zeroes until the number of digits/characters equals 8.

If parameter _prefix_ is specified, it will additionally add the inputted string in the beginning of the ID string. If _prefix_ is not specified, it will not add anything else. The adding of the prefix happens before the insertion of additional zeroes, i.e. zeroes will be inserted between prefix and ID number until the total number of digits/characters (including the prefix) equals the specified length.

Usually used when creating a new record to insert into the repository (see "Insert Record").

## Example

The following program illustrates the function call:

```
var newId = repo.NewID(x => x.ID, 10, "EU");
```

The function will generate the new ID "EU00000120" (for the case that the newest record that is currently in the repository has the Primary Key Value "119") for the Primary Key column "ID" and store it in the variable "newId".

