I have a Generic Repository pattern with UnitOfWork and i am using IoC. Other than the base methods used by the repository, i have some custom methods. Instead of implementing the whole IRepository methods again, i have inherited from the GenericRepository class. 

Here is my UnitofWork implementation:

```
public interface IUnitOfWork<T> : IDisposable where T : DbContext
{
    int Save();
    T Context { get; }
}

public class UnitOfWork<T> : IUnitOfWork<T> where T : MyContext, new()
{
    private readonly T _context;

    public UnitOfWork()
    {
        _context = new T();
    }

    public UnitOfWork(T Context)
    {
        _context = Context;
    }

    public int Save()
    {
        return _context.SaveChanges();
    }

    public T Context
    {
        get
        {
            return _context;
        }
    }

    public void Dispose()
    {
        _context.Dispose();
    }
}

```

This my Repository implementation:

```
    public interface IGenericRepository
{
    IQueryable<T> All<T>() where T : class;
    void Remove<T>(int id)where T : class;
    void Remove<T>(T entity) where T : class;
    void RemoveRange<T>(IList<T> entities) where T : class;
    T Find<T>(int id) where T : class;
    void Add<T>(T entity) where T : class;
    void AddRange<T>(IList<T> entities) where T : class;
    void Update<T>(T entity) where T : class;
    int SaveChanges();
}

  public class GenericRepository<C> : IGenericRepository where C : MyContext
{
    protected readonly C _context;

    public GenericRepository(IUnitOfWork<C> unitOfWork)
    {
        _context = unitOfWork.Context;
    }

    public int SaveChanges()
    {
       return  _context.SaveChanges();
    }

    public IQueryable<T> All<T>() where T : class
    {
        return _context.Set<T>();
    }

    public void Remove<T>(int id) where T : class
    {
        T entity = _context.Set<T>().Find(id);
        if (entity != null)
        {
            _context.Set<T>().Remove(entity);
        }
    }

    public void Remove<T>(T entity) where T : class
    {
        if (entity != null)
        {
            _context.Set<T>().Remove(entity);
        }
    }

    public void RemoveRange<T>(IList<T> entities) where T : class
    {
        if (entities.Count > 0)
        {
            _context.Set<T>().RemoveRange(entities);
        }
    }

    public T Find<T>(int id) where T : class
    {
        return _context.Set<T>().Find(id);
    }

    public void Add<T>(T entity) where T : class
    {
        _context.Set<T>().Add(entity);
    }

    public void AddRange<T>(IList<T> entities) where T : class
    {
        _context.Set<T>().AddRange(entities);
    }

    public void Update<T>(T entity) where T : class
    {
        _context.Set<T>().Attach(entity);
        _context.Entry(entity).State = System.Data.Entity.EntityState.Modified;
    }
}

```

Here is an example of Custom-Repository:

```
public interface IUserAccountRepository : IGenericRepository
{
    UserAccount Find(string email, string password);
    bool CheckDuplicate(string email);
}

 public class UserAccountRepository<C> : GenericRepository<C> where C : CSharpAssigmentContext, IUserAccountRepository
{
    protected readonly C _context;

    public UserAccountRepository(IUnitOfWork<C> unitOfWork)
    {
        _context = unitOfWork.Context;
    }

    public int SaveChanges()
    {
       return  _context.SaveChanges();
    }

    /// <summary>
    /// Find user by email and password
    /// </summary>
    public UserAccount Find(string email, string password)
    {
        return _context.Set<UserAccount>().Where(ua => ua.Email == email && ua.Password == password).FirstOrDefault(null);
    }

    /// <summary>
    /// Check wether user exists or not
    /// </summary>
    public bool CheckDuplicate(string email)
    {
        return _context.Set<UserAccount>().Any(ua => ua.Email == email);
    }

    public IQueryable<T> All<T>() where T : class
    {
        return _context.Set<T>();
    }

    public void Remove<T>(int id) where T : class
    {
        T entity = _context.Set<T>().Find(id);
        if (entity != null)
        {
            _context.Set<T>().Remove(entity);
        }
    }

    public void Remove<T>(T entity) where T : class
    {
        if (entity != null)
        {
            _context.Set<T>().Remove(entity);
        }
    }

    public void RemoveRange<T>(IList<T> entities) where T : class
    {
        if (entities.Count > 0)
        {
            _context.Set<T>().RemoveRange(entities);
        }
    }

    public T Find<T>(int id) where T : class
    {
        return _context.Set<T>().Find(id);
    }

    public void Add<T>(T entity) where T : class
    {
        _context.Set<T>().Add(entity);
    }

    public void AddRange<T>(IList<T> entities) where T : class
    {
        _context.Set<T>().AddRange(entities);
    }

    public void Update<T>(T entity) where T : class
    {
        _context.Set<T>().Attach(entity);
        _context.Entry(entity).State = System.Data.Entity.EntityState.Modified;
    }

```

Here is my Unity IoC code:

```
    public static class UnityConfig
{
    public static void RegisterComponents()
    {
        var container = new UnityContainer();

        //UnitOfWork and GenericRepository
        container.RegisterType(typeof(IUnitOfWork<CSharpAssigmentContext>),typeof(UnitOfWork<CSharpAssigmentContext>), new HierarchicalLifetimeManager());
        container.RegisterType(typeof(IGenericRepository), typeof(GenericRepository<CSharpAssigmentContext>), new HierarchicalLifetimeManager());

        //I keep receiving compile ERROR here
        container.RegisterType(typeof(IUserAccountRepository), typeof(UserAccountRepository<CSharpAssigmentContext>), new HierarchicalLifetimeManager());

        //Services
        container.RegisterType(typeof(IUsersAccountsService), typeof(UsersAccountsService), new TransientLifetimeManager());

        DependencyResolver.SetResolver(new UnityDependencyResolver(container));
    }
}

```

As mentioned in the code, i keep getting a compile time error for the following code:

```
container.RegisterType(typeof(IUserAccountRepository), typeof(UserAccountRepository<CSharpAssigmentContext>), new HierarchicalLifetimeManager());

```

The error is:

> 
> The type MyContext can't be used as type parameter C in the generic type or method. There is no implicate reference conversion from MyContext to IMyClassRepository.
> 
> 
> 

How to solve this error? Is my implementation correct for custom repositories?