Is it possible to perform _session.query on startup file, i am getting error Unable to resolve service for type 'YesSql.ISession' #10973
Replies: 3 comments 5 replies
-
It's not resolved yet, the |
Beta Was this translation helpful? Give feedback.
-
If you need to get a configuration value from the database you should use an options pattern, and resolve it from an options provider, as it will be built lazily, in the scope that actually needs the value. Here is an example, which is accessing site settings, you should be able to build on that. |
Beta Was this translation helpful? Give feedback.
-
with the below i was able to get documents (stored on db) on startup, by registering ModularTenantEvents public class D365CEGetOrganizationService : ModularTenantEvents
{
private readonly ILogger<D365CEGetOrganizationService> _logger;
private readonly ISession _session;
private readonly INotifier _notifier;
private readonly dynamic New;
private readonly IHtmlLocalizer H;
private readonly IStringLocalizer S;
public D365CEGetOrganizationService(
ISession session,
INotifier notifier,
ILogger<D365CEGetOrganizationService> logger,
IHtmlLocalizer<D365CEGetOrganizationService> htmlLocalizer,
IStringLocalizer<D365CEGetOrganizationService> stringLocalizer,
IShapeFactory shapeFactory)
{
_session = session;
_logger = logger;
_notifier = notifier;
New = shapeFactory;
H = htmlLocalizer;
S = stringLocalizer;
}
public override async Task<Task> ActivatingAsync()
{
var Documents = await _session.Query<D365CEViewModel>().FirstOrDefaultAsync();
if (Documents != null)
{
var _orgService = CE.GetOrganizationServiceClientSecret(
Documents.OrganizationName
);
_logger.LogInformation("A tenant has been activated.");
await _notifier.SuccessAsync(H["Welcome to the .", Documents.OrganizationName]);
}
return null;
}
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to perform _session.query on startup file, i am getting error Unable to resolve service for type 'YesSql.ISession'
Beta Was this translation helpful? Give feedback.
All reactions