-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get the set connection string to the static options? #26
Comments
Looks good to me! |
It looks good but the things is like this I get the following build error
when trying to use Configuration.GetConnectionString("connectionString") like I do in the example above. But after some trial and error I managed to get this to work with with both sql and in-memory. UseCachedSqlFeatureProviderprivate readonly FeatureFlagOptions options;
public Startup(IConfiguration configuration, IHostingEnvironment env)
{
Configuration = configuration;
options = new FeatureFlagOptions()
{
FeatureFlagAssemblies = new[] {
typeof(MyServiceLayerThatUsesthis).Assembly
,typeof(MyFeatureClassInMyCoreLib).Assembly
}}.UseCachedSqlFeatureProvider(Configuration.GetConnectionString("DefaultConnection"));
} And staticly with UseInMemoryFeatureProviderlike this (with no need for a connection string) public static readonly FeatureFlagOptions options = new FeatureFlagOptions
{
FeatureFlagAssemblies = new[] {
typeof(MyServiceLayerThatUsesthis).Assembly
,typeof(MyFeatureClassInMyCoreLib).Assembly
}}.UseInMemoryFeatureProvider();
And then using options like before. Explanation of codeMyServiceLayerThatUsesthis == I use this in my servicelayer togling not in a Controller. UseCachedSqlFeatureProviderI would add some doc that lets us know that UseCachedSqlFeatureProvider creates a table RimDevAspNetCoreFeatureFlags where it stores the flags. QuestionBut could you quickly tell me the difference between the two? ThanksBut all in all I really like this. Thanks for creating it! |
Updating sample code to use |
There are probably lots of ways to do this but how do you recommend doing this?
Like the code below?
The text was updated successfully, but these errors were encountered: