# Overriding Existing Methods

As you can see in standard implementation, all methods are marked as virtual which means you can customize their content via overriding them.

You can override the existing methods to create a new class. To do that, newly created classes should inherit from _**RENUnitOfWork**_ class:

```csharp
public class MyUnitOfWork<TDbContext> : RENUnitOfWork<TDbContext> where TDbContext : RENDbContext
{
    public MyUnitOfWork(TDbContext context) : base(context) { }

    public override IRENRepository<TEntity>? GetRENRepository<TEntity>()
    {
        // Make custom actions here
        return base.GetRENRepository<TEntity>();
    }
    
    // we didn't override SaveChanges() method because we don't want to change it's behaviour
}
```

{% hint style="info" %}
Here, we use T is _**RENDbContext**_ because _**RENDbContext**_ is already DbContext!
{% endhint %}

Here, we overrided the existing method to expand it's functionality. From now on, we have register _**MyUnitOfWork**_ in _**Program.cs**_ instead of standard registeration:

```csharp
// builder.Services.RegisterRENDatabaseAccessHelpers(); // SINCE WE ARE NOT USING STANDARD APPROACH ANYMORE
builder.Services.AddScoped(typeof(IRENUnitOfWork<>), typeof(MyUnitOfWork<>));
```

And we may inject it to our classes:

```csharp
public class HomeController : ControllerBase
{
    private readonly IRENUnitOfWork<RENDbContext> _uow;
    private readonly IRENRepository<User> _customUserRepository;

    public HomeController(IRENUnitOfWork<RENDbContext> uow)
    {
        _uow = uow;
        _customUserRepository = uow.GetRENRepository<User>();
    }
}
```

Here, you will use your _**MyUnitOfWork**_ class thanks to registeration.
