ABP sets TenantId for IMustHaveTenant but not for IMayHaveTenant.
I tried using IMustHaveTenant when calling Update method of the repository it and it does not set it. It actually throws an exception because value is 0.
aaron I still dont understand how IMustHaveTenant works. Tried to read the documentation but it does not say much apart from IMustHaveTenant defines the TenantId property to distinguish between different tenant entities. ASP.NET Boilerplate uses the IAbpSession to get the current TenantId by default and automatically filters the query for the current tenant.
How does it work with Update and Insert methods.
Cant find any example. Do I need to set TenantId when updating or inserting or IMustHaveTenant does it automatically?
Also If I set it manually does IMustHaveTenant checks if that TenantId is the correct one when updating a record?
I am not saying about the query execution. I was talking about how it intercepts and modify query when IMustHaveTenant is there.
I followed the instructions there but they are not very clear and I can't make it work
namespace MyProject.Core.Extended
{
public class MyProjectCoreExtendedModule : AbpModule
{
public override void PreInitialize()
{
Configuration.Localization.Sources.Extensions.Add(
new LocalizationSourceExtensionInfo(MyProjectConsts.LocalizationSourceName,
new XmlEmbeddedFileLocalizationDictionaryProvider(Assembly.GetExecutingAssembly(),
"MyProject.Core.Extended.Localization.MyProject"
)
)
);
}
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(typeof(MyProjectCoreExtendedModule).GetAssembly());
}
}
}
Thanks @aaron for your help. Have checked the IMayHaveTenant documentation.
I have one last question to that.
How does this affect performance? To use a filter it means whenever i request something from database using IRepository it intercepts request and adds TenantId. IMHO this results in performance penalty opposed to do it manually when requesting it (x.TenantId = user.TenantId)
Thanks
how do I override it for nswag?
I have noticed that nswag refresh script creates camelcase models on angular ts. On server I have the following model
public class Client
{
public string Name {get;set;}
public DateTime DateOfBirth {get;set;}
}
in angular I get the following
name!: string | undefined;
dateOfBirth!: string | undefined;
How do I force it to keep the same names?
Thanks
AbpSession.TenantId cannot be tampered or changed by the ?
Yes I know how to retrieve it.
What I am asking is when I do a where x.TenantId = tenantId; What shall I use the AbpSession.ToUserIdentifier().TenantId or the UserManager.FindByIdAsync(...).TenantId as tenantId.
In terms of security what is the correct approach?