# Implementing Additional Methods

Surely you should be able to implement new functions addition to existing one if you need it. This is SOLID after all! Let's see how we can do this. First you need to create the interface that inherits from _**IRENRepository**_ interface. Your new interface should contain additional methods:

```csharp
public interface IMyRepository<TEntity> : IRENRepository<TEntity> where TEntity : class
{
    Task MyCustomFunction(CancellationToken cancellationToken = default);
}
```

Then create your _**MyRepository**_ class that inherits from _**IMyRepository**_:

```csharp
public class MyRepository<TEntity> : RENRepository<TEntity>, IMyRepository<TEntity> where TEntity : class
{
    public MyRepository(RENDbContext context) : base(context) { }

    public Task MyCustomFunction(CancellationToken cancellationToken = default)
    {
        return Task.Factory.StartNew(() =>
        {
            cancellationToken.ThrowIfCancellationRequested();
            Console.WriteLine("This is my custom Function");
            // other custom implementations!

        }, cancellationToken);
    }
}
```

{% hint style="info" %}
Since we created new interface and want to use it, we can not override the _**GetRENRepository**_ function because we want a function that returns our newly created interface.
{% endhint %}

Customize our UnitOfWork class to return our newly created interface:

```csharp
public class MyUnitOfWork<TDbContext> : RENUnitOfWork<TDbContext>, IMyUnitOfWork<TDbContext> where TDbContext : RENDbContext
{
    public MyUnitOfWork(TDbContext context) : base(context) { }
    
    public IMyRepository<TEntity>? GetMyRepository<TEntity>() where TEntity: class
    {
        return (IMyRepository<TEntity>?)Activator.CreateInstance(typeof(MyRepository<TEntity>), new object[] { _context });
    }
}
```

Also update the interface:

```csharp
public interface IMyUnitOfWork<TDbContext>: IRENUnitOfWork<TDbContext> where TDbContext : RENDbContext
{
    IMyRepository<TEntity>? GetMyRepository<TEntity>() where TEntity : class;
}
```

Register your custom _**UnitOfWork**_ class in your _**Program.cs:**_

```csharp
builder.Services.AddScoped(typeof(IMyUnitOfWork<>), typeof(MyUnitOfWork<>));
```

And you can get and use your custom repository like this:

```csharp
public class HomeController : ControllerBase
{
    private readonly IMyRepository<User> _userRepository;

    public HomeController(IMyUnitOfWork<RENDbContext> uow)
    {
        _userRepository = uow.GetMyRepository<User>();
    }
    
    [HttpGet, Route("Index")]
    public async Task<IActionResult> Index()
    {
        await _userRepository.MyCustomFunction();
        return Ok();
    }
}
```
