I would like to know if we can store variables (from CLR Functions) on global scope; something which is comparable to Application Scope in APS.Net which lets us access variables across processes and calls. I am planning to keep a dictionary object on the global scope. Need to know if this is possible.
Regards-
Muralidhar |
If my response helped, please help me by marking my response as the answer and voting as appropriate...
Since you are in a database, why not store your state in a database table? A dictionary object is just a table with primary key.
You can use static variables, but since SQLCLR frowns on you using your own locking (for reliability's sake), if the static variable is mutable, the assembly must be cataloged as unsafe. And the appdomain may be removed. If you can initialize your static variable in the class constructor (and therefore mark it readonly) you can catalog the assembly as safe.
Since you are in a database, why not store your state in a database table? A dictionary object is just a table with primary key.
You can use static variables, but since SQLCLR frowns on you using your own locking (for reliability's sake), if the static variable is mutable, the assembly must be cataloged as unsafe. And the appdomain may be removed. If you can initialize your static variable in the class constructor (and therefore mark it readonly) you can catalog the assembly as safe.