C # Web Service and using a variable

I need to create a project for several web services using WCF in C #. Web services will call other assemblies to perform basic processing. In assemblies, data from SQL Server will be available. One of the parameters that will be part of each web service method will include a database to use. My problem is how to pass the database parameter to the assembly for use. I cannot change all signatures for all satellite assemblies. I want to refer to some kind of variable that the satellite collects. The same satellite assemblies are used with the Windows Forms application and the ASP.NET application, so I will need to have something that all types of applications can use. Static fields are not suitable, because for one call to the web service, the database may be "X", and for another - "Y".Any ideas?

+3
source share
1 answer

This is something that can go well with the IoC or DI framework - having some interface that includes database information, and made it insert all the callers for you. Even without IoC, hiding the implementation in an interface sounds like a complete plan.

static; a [ThreadStatic] , ( ), , Principal, WCF ( ) winforms ( ). , (async ..). , , ASP.NET .

+2

Source: https://habr.com/ru/post/1727700/


All Articles