Hi, I am using OrmLiteAuthRepositoryMultitenancy to allow me to move my app to a multi-tenant architecture. I have wired it up as per the details in your docs. However, when I use IAuthRespository.GetUserAuth in other classes as a dependency I get:
‘ExecuteReader requires an open and available Connection. The connection’s current state is closed.’
I am using IAuthRepository as a standard property dependency, what am I doing wrong?
public class UserDataAppender : IUserDataAppender
{
private ConcurrentDictionary<string, IUserAuth> _retrievedUsers;
public IAuthRepository AuthRepository { get; set; }
public UserDataAppender()
{
_retrievedUsers = new ConcurrentDictionary<string, IUserAuth>();
}
private IUserAuth GetUser(string id)
{
if (id == null) return null;
if (_retrievedUsers.ContainsKey(id.ToString()))
return _retrievedUsers[id.ToString()];
else
{
**var user = AuthRepository.GetUserAuth(id.ToString());**
_retrievedUsers.TryAdd(id.ToString(), user);
return user;
}
}
}
my AppHost.GetAuthRepository looks like (RoleBasedAuthRepository derives from OrmLiteAuthRepositoryMultiTenancy and just concatenates permissions based on roles, cretainly not closing any connection).
public override IAuthRepository GetAuthRepository(IRequest req = null)
{
return req != null
? new RoleBasedAuthRepository(GetDbConnection(req)) //At Runtime
: TryResolve<IAuthRepository>(); //On Startup
}