question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ISettingManager does'nt filter tenantId in a Console App

See original GitHub issue

Hello Dears I have an issue that confuses me. In a Console Application I want to use ISettingManager with multi tenancy but I it doesn’t filter tenantId.

This is my code:

using (_unitOfWorkManager.Current.EnableFilter(AbpDataFilters.MayHaveTenant))
            {
               var test=  _settingManager.GetSettingValue("App.ForgotPasswordUrl");
            }

BookingSystemAppModule:

  public override void PreInitialize()
        {
            Configuration.DefaultNameOrConnectionString =                
            ConfigurationManager.ConnectionStrings["Default"].ConnectionString;
            Configuration.MultiTenancy.IsEnabled = true;
            Configuration.Settings.Providers.Insert(1, typeof(BookingSystemSettingProvider));
            Configuration.Settings.Providers.Remove(typeof(AbpZeroSettingProvider));
        }
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
        }

public class BookingSystemSettingProvider : SettingProvider
    {
        public override IEnumerable<SettingDefinition> GetSettingDefinitions(SettingDefinitionProviderContext context)
        {
            return new List<SettingDefinition>
            {
                new SettingDefinition(
                    AppSettingNames.ForgotPasswordUrl,
                    null,
                    scopes: SettingScopes.Tenant,
                    clientVisibilityProvider: new VisibleSettingClientVisibilityProvider()
                )
            };
        }
    }

And The SQL query:

exec sp_executesql N'SELECT [e].[Id], [e].[CreationTime], [e].[CreatorUserId], [e].[LastModificationTime], [e].[LastModifierUserId], [e].[Name], [e].[TenantId], [e].[UserId], [e].[Value]
FROM [Settings] AS [e]
WHERE ([e].[TenantId] IS NULL OR (CASE
    WHEN [e].[TenantId] IS NULL
    THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT)
END = @__ef_filter__IsMayHaveTenantFilterEnabled_1)) AND ([e].[UserId] IS NULL AND [e].[TenantId] IS NULL)',N'@__ef_filter__IsMayHaveTenantFilterEnabled_1 bit',@__ef_filter__IsMayHaveTenantFilterEnabled_1=0

Thanks a lot Mehran Hafizi

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ismcagdascommented, Jun 24, 2019

@Mehranh could you try using https://aspnetboilerplate.com/Pages/Documents/Abp-Session#user-identifier instead of _unitOfWorkManager.Current.SetTenantId ?

1reaction
ismcagdascommented, Oct 19, 2021

@rgiosa could you create a new issue and share a sample code ? Normally setting the current tenant on the unitOfWork should filter the data.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding Filters to a .Net Core Console application #44321
I have everything set up and working, and I can see test messages from my console app appear in Application Insights but ONLY...
Read more >
Support Center - ABP Commercial
ABP Commercial official channel for technical support. Ask questions, report issues, search for already solved issues.
Read more >
Dynamic scoped dependency resolution in a console app ...
Suppose the app processes items from a multi-tenant queue and each message can belong to a different tenant. While processing each message, it ......
Read more >
ASP.NET Boilerplate v5+ to ABP Framework Migration
ABP Framework is the successor of the open source ASP.NET Boilerplate framework. This guide aims to help you to migrate your existing ...
Read more >
How to Use Action Filter in Winform App Console app OR ...
First you need to create a class and extend it from ActionFilterAttribute. now it has four methods that are shown below. you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found