Base solution for your next web application
Open Closed

Static class per tennant #8570


User avatar
0
fawad29 created

If I declare a class as static what will be the scope of it, will it be application wide or tenant wide. I would like to store validation error messages in a database table, each tenant will have their own set of validation error messages. I was thinking of loading error messages for each tenant and keep them in cache in a static class so that I dont' have to inject it all the time as the error message will not change and keep the resources as low as possible. However, each tenant can have their own set of error messages so I was wondering about the scope of static class. As you know in c#, a static class exists only once so their only one copy of data so I was wondering how my proposed design will work. Or if you have an alternative way of handling it in ANZ, then please suggest.


1 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    The use of static classes is not recommended. It is not friendly to unit tests. You can create a service, cache the contents of the database in the service, and update the cache based on entity change events.