# Usage of Parameters

While using RENHelpers, you may need spesific operatons such as ordering, including etc. This section covers how you can send these parameters to apply desired rules.

Assume we have the following database:

<figure><img src="https://3545698740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1gvCT6GY5YmzyoZihAf1%2Fuploads%2F0OoJhHSRV3dfUA02SwTM%2Fimage.png?alt=media&#x26;token=40e81ac7-e0a4-4bc4-a37b-ccf34442c456" alt=""><figcaption></figcaption></figure>

Here are the relationships:

* 1 user should have only 1 side, but there could be multiple user for 1 side (1-\*)
* 1 side should only have 1 test, and 1 test must only belong to 1 side (1-1)
* 1 test should have multiple test descriptions, while 1 test description must belong to only one test (1-\*)

{% hint style="info" %}
All the examples will be shown on async functions of the repository. But please note that all this parameter calls can be applied to the functions' sync versions.
{% endhint %}

1. **Filter:**

To filter a query, you can call filter parameter like this:

```csharp
Route("api/[controller]")]
[ApiController]
public class HomeController : ControllerBase
{
    private readonly IRENRepository<Side> _sideRepository;
    
    public HomeController(IRENUnitOfWork<RENDbContext> uow)
    {
        _sideRepository = uow.GetRENRepository<Side>();
    }
    
    [HttpGet]
    [Route("GetLightSides")]
    public async Task<IActionResult> GetLightSides()
    {
        List<Side> lightSideList = await _sideRepository.GetListAsync(filter: _ => _.Name == "Light Side");
        IQueryable<Side> lightSideQueryable = await _sideRepository.GetQueryableAsync(filter: _ => _.Name == "Light Side");
        Side lightSide = await _sideRepository.GetSingleAsync(filter: _ => _.Name == "Light Side");

        return Ok();
    }
}
```

2. **Order By:**

To order a query, you can call order parameter like this:

```csharp
Route("api/[controller]")]
[ApiController]
public class HomeController : ControllerBase
{
    private readonly IRENRepository<User> _userRepository;
    
    public HomeController(IRENUnitOfWork<RENDbContext> uow)
    {
        _userRepository= uow.GetRENRepository<User>();
    }
    
    [HttpGet]
    [Route("GetUsersOrdered")]
    public async Task<IActionResult> GetUsersOrdered()
    {
        List<User> orderedUsersList = await _userRepository.GetListAsync(orderBy: _ => _.OrderBy(_ => _.Name).ThenByDescending(_=>_.Id));
        IQueryable<User> orderedUserQueryable = await _userRepository.GetQueryableAsync(orderBy: _ => _.OrderBy(_ => _.Name).ThenBy(_=>_.Id));

        return Ok();
    }
}
```

3. **Include:**

To include navigation properties to a query, you can call include parameter like this:

```csharp
Route("api/[controller]")]
[ApiController]
public class HomeController : ControllerBase
{
    private readonly IRENRepository<User> _userRepository;
    
    public HomeController(IRENUnitOfWork<RENDbContext> uow)
    {
        _userRepository= uow.GetRENRepository<User>();
    }
    
    [HttpGet]
    [Route("GetLightSideUsers")]
    public async Task<IActionResult> GetLightSideUsers()
    {
        var lightSideUsersList = await _userRepository.GetListAsync(include: i => i.Include(_=>_.Side).ThenInclude(_=>_.Test).ThenInclude(_=>_.TestDescriptions), filter:_=>_.Side.Name == "Light Side");
        var lightSideUsersQueryable = await _userRepository.GetQueryableAsync(include: i => i.Include(_ => _.Side).ThenInclude(_=>_.Test).ThenInclude(_=>_.TestDescriptions), filter:_=>_.Side.Name == "Light Side");
        var lightSideUser = await _userRepository.GetSingleAsync(include: i => i.Include(_ => _.Side).ThenInclude(_=>_.Test).ThenInclude(_=>_.TestDescriptions), filter: _=> _.Side.Name == "Light Side" && _.Name == "Anakin");
    
        return Ok();
    }
}
```

4. **Read Only:**

Too make query readonly, you can call isReadOnly parameter like this:

```csharp
Route("api/[controller]")]
[ApiController]
public class HomeController : ControllerBase
{
    private readonly IRENRepository<User> _userRepository;
    
    public HomeController(IRENUnitOfWork<RENDbContext> uow)
    {
        _userRepository= uow.GetRENRepository<User>();
    }
    
    [HttpGet]
    [Route("GetLightSideUsers")]
    public async Task<IActionResult> GetLightSideUsers()
    {
        var lightSideUsersList = await _userRepository.GetListAsync(isReadOnly: true);
        var lightSideUsersQueryable = await _userRepository.GetQueryableAsync(isReadOnly: true);
        var lightSideUser = await _userRepository.GetSingleAsync(filter: _=>_.Id == 1, isReadOnly: false);
        
        return Ok();
    }
}
```
