public IList<OAuth2Scope> GetScopes(OAuth2ScopeType scopeType) { IList<OAuth2Scope> set = null; using (IEntityContext context = DependencyInjection.Get<IEntityContext>()) { using (IOAuth2ScopeRepository repository = DependencyInjection.Get<IOAuth2ScopeRepository>(InjectionParameter.Create("context", context))) { string scopeCodeBase = string.Empty; // Set the value of the scope code to be retrieved. switch (scopeType) { case OAuth2ScopeType.Client: scopeCodeBase = "application.client.role."; break; case OAuth2ScopeType.User: scopeCodeBase = "application.user.role."; break; default: break; } var query = repository.Query() .Where(x => x.Code.IsInsensitiveLike(scopeCodeBase, MatchMode.Start)) .AndNot(x=>x.Code.IsInsensitiveLike("guest", MatchMode.End)); set = query.List(); } context.Commit(); } return set; }