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.

Per-tenant options not set for a class

See original GitHub issue

Hello,

I’ve been implementing a custom MultiTenantStore, since i am using a nosql database to store tenants. Now that part works as it seems, since i get the TenantInfo when i get the MultiTenantContext. Now the part where i setup per-tenant options for a class, , called TenantOptions, and has one property “ConnectionString”, which i use to inject into my MongoContext to connect to the tenant-specific database, is not working apparently. What i am doing is: services.AddMultiTenant() //strategy ... //store .. //.WithPerTenantOptions<TenantOptions>((to, ti) => {to.ConnectionString = ti.ConnectionString})

Apparently whenever the TenantOptions instance is called by the MongoContext, the ConnectionString is null. I’m not sure if i am using the WithPerTenantOptions<TOptions>() method correctly. Please do point me what i am doing wrong. Many thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AndrewTriesToCodecommented, May 23, 2019

Hi @vlatkozmejkoski Can you post a sample of what your TenantOptions class looks like? Also is TenantOptions registered for DI as a singleton, scoped, or transient?

In theory, in your mongo db setup area you will inject IOptions<TenantOptions>, IOptionsSnaption<TenantOptions>, or IOptionsMonitor<TenantOptions> from which you get the TenantOptions instance and it should pick up the tenant info.

If you are only using TenantOptions to get the connection string you can skip a lot of this… just inject TenantInfo into your mongo db setup area and use the connection string on TenantInfo directly.

0reactions
AndrewTriesToCodecommented, Jul 9, 2019

Thanks for letting me know. I will take a look at how the library interacts with authorization policies and related requirements.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Override get, but not set
I have an abstract class that defines a get , but not set , because as far as that abstract class is concerned,...
Read more >
How to override !important? - css
Apart from overriding a style set by the style attribute, the !important should only be used when you have selectors in your style...
Read more >
Configuration
A guide to configuring and customizing your Tailwind installation.
Read more >
2 Setting the Class Path
The following commands have a -classpath option that replaces the path or paths specified by the CLASSPATH environment variable while the tool runs:...
Read more >
NotImplementedException Class (System)
The NotImplementedException exception is thrown when a particular method, get accessor, or set accessor is present as a member of a type but...
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