Constructor
# new SqlCacheDependency(connectionString, cmdText, cmdType, cmdParams)
Initializes a new instance of the SqlCacheDependency class, using the supplied connection string and query string. This constructor is used to create SqlCacheDependency objects that use the query-notification feature of SQL Server 2005 products. SQL query must include the following: Fully qualified table names, including the name of the table owner. For example, to refer to a table called "customers" that is owned by the database owner, the SQL statement must refer to "dbo.customers". Explicit column names in the Select statement. You cannot use the asterisk (*) wildcard character to select all columns from a table. For example, instead of "select * from customers", you must use "select name, address, city, state from dbo.customers".
| Name | Type | Description | 
|---|---|---|
| connectionString | String | connection string to be used by dependency. | 
| cmdText | String | cmdText to be used by dependency. | 
| cmdType | SqlCommandType | The type of the command. (text/stored procedure) | 
| cmdParams | Map | Parameters to be passed to the command. | 
//Initialize the Cache Cluster 
let cache = await ncache.CacheManager.getCache("demoCache");
 //SQL server configuration
let connectionString = "Data Source=SERVER;Database=temp;User ID=Admin;password = xxxxxxx";
//SQL query 
let queryString = "SELECT ProductID, ProductName, QuantityPerUnit, UnitPrice FROM dbo.PRODUCTS WHERE PRODUCTID = 1";
//Create SqlCacheDependency object
let sqlServerDependency = new ncache.SqlCacheDependency(connectionString, queryString );
// Create CacheItem
let caceItem = new ncache.CacheItem("Value:SqlCacheDependency-test");
//Set dependency of cache item
caceItem.setDependency(sqlServerDependency);
let cacheItemVersion = await cache.add("Key:SqlCacheDependency", caceItem);Methods
# getCommandParams() → {Map}
Parameters to be used by dependency.
Returns Map<String, SqlCmdParams>.
- Type
- Map
# getCommandText() → {String}
CommandText to be used by dependency.
Returns CommandText.
- Type
- String
# getCommandType() → {CommandType}
Describes the type of the SQL command passed to the SQLDependency.
Returns type of the SQL command.
- Type
- CommandType
# getConnectionString() → {String}
Connection String is the connection string that is required to the cache in order to connect with database.
Returns Connection String.
- Type
- String