ISettingManager does'nt filter tenantId in a Console App
See original GitHub issueHello 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:
- Created 4 years ago
- Comments:11 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Mehranh could you try using https://aspnetboilerplate.com/Pages/Documents/Abp-Session#user-identifier instead of _unitOfWorkManager.Current.SetTenantId ?
@rgiosa could you create a new issue and share a sample code ? Normally setting the current tenant on the unitOfWork should filter the data.