Ok, so it's been a while when I create my questions, I resolve this with changing from property injection into constructor injection like this:
public class MyRepository
{
private static AnotherClass _anotherClass;
private readonly IBaseRepository _baseRepository;
private readonly IUid _uid;
public MyRepository(IBaseRepository _baseRepository, IUid uid)
{
_baseRepository = baseRepository;
_uid = uid;
_anotherClass = BaseRepository.Db.SingleOrDefault<AnotherClass>();
//another logic in here....
}
public string MethodUsingUid()
{
return _uid.SomeMethodHere(_anotherClass);
}
}
And I move the injection to Service:
public class TheServices : Service
{
public IBaseRepository BaseRepository { get; set; } //Injected By IoC
public IUid Uid { get; set; } // Injected By IoC
public object Post(some_Dto dto)
{
var Repo= new MyRepository(BaseRepository, Uid);
return Repo.MethodUsingUid();
}
}
I Hope there's another way, but it's only solutions that I can think.