Activities of "liangshiwei"

Answer

Hi,

Add the following code to your HttpApi.Host project module class:

private static void ConfigureSwagger(ServiceConfigurationContext context)
{
    context.Services.AddSwaggerGen(
        options =>
        {
            options.SwaggerDoc("v1", new OpenApiInfo {Title = "qaangularng API", Version = "v1"});
            options.DocInclusionPredicate((docName, description) => true);
            options.CustomSchemaIds(type => type.ToString()); // add this line
        });
}

It will fix in next version.

Answer

I will check it out

Does https://stackoverflow.com/questions/37213937/asp-net-mvc-core-replace-controllers-using-custom-class-library work for you?

I think should not expose service as OrganizationUnitManager, should be IOrganizationUnitAppService.

Hi,

I think you can create an interface, like:

public interface IMyOrganizationRepository : IOrganizationUnitRepository
{
    public Task GetCustomerAsync();
}

[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IOrganizationUnitRepository), typeof(IMyOrganizationRepository))]
public class EfCoreAppOrganizationUnitRepository : EfCoreOrganizationUnitRepository, IMyOrganizationRepository
{
    public EfCoreAppOrganizationUnitRepository(IDbContextProvider<IIdentityDbContext> dbContextProvider) : base(
        dbContextProvider)
    {
    }

    public Task GetCustomerAsync()
    {
        return Task.CompletedTask;
    }
}

public class OrganizationUnitsAppService : OrganizationUnitAppService
{
    public OrganizationUnitsAppService(
        IOrganizationUnitRepository organizationUnitRepository)
        : base(organizationUnitRepository)
    {
    }

    public Task GetMember()
    {
        return ((IMyOrganizationRepository)OrganizationUnitRepository).GetCustomerAsync();
    }
}

Hi,

It has replaced the default tenant resolver and full compatible, If it is not CustomerDbContext it will fall back to the default resolver. If you use the repository infrastructure provided by abp, it should work seamlessly.

Hi,

This is just a simple example,

Identifying how to login a user via the mobile app using the ABP login API without prior knowledge of what tenant that user belongs to

It is not possible to log in to the application without knowing the tenant, because the user may be under any one of the tenants and may have the same user name. You need to determine the tenant when logging in.

You must have some rules for determining the tenant at login.

Hi, here is a simple example;

[ConnectionStringName("CustomerDbContext")]
public class CustomerDbContext : AbpDbContext<CustomerDbContext>
{
    ......
}
[Dependency(ReplaceServices = true)]
public class CustomConnectionStringResolver : MultiTenantConnectionStringResolver
{
    private readonly ICurrentUser _currentUser;

    private readonly IDistributedCache _distributedCache;
    public CustomConnectionStringResolver
        (IOptionsSnapshot<AbpDbConnectionOptions> options,
        ICurrentTenant currentTenant, IServiceProvider serviceProvider,
        ICurrentUser currentUser, IDistributedCache distributedCache) :
        base(options, currentTenant, serviceProvider)
    {
        _currentUser = currentUser;
        _distributedCache = distributedCache;
    }

    public override string Resolve(string connectionStringName = null)
    {
        if (connectionStringName != null && connectionStringName == "CustomerDbContext")
        {
            var connectionString = ResolveCustomConnectionString();
            if (!connectionString.IsNullOrWhiteSpace())
            {
                return connectionString;
            }
        }
        return base.Resolve(connectionStringName);
    }

    private string ResolveCustomConnectionString()
    {
        //query the custom connection string
        return _distributedCache.GetString(nameof(CustomConnectionStringResolver) + _currentUser.Name);
    }
}

Can you explain the case in details

May https://github.com/abpframework/abp-samples/tree/master/DocumentationSamples/CustomApplicationModules can help you.

Showing 6291 to 6300 of 6692 entries
Learn More, Pay Less
33% OFF
All Trainings!
Get Your Deal
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 10, 2025, 06:30