SqlCacheDependencySection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为 ASP.NET 应用程序配置 SQL 缓存依赖项。 此类不能被继承。
public ref class SqlCacheDependencySection sealed : System::Configuration::ConfigurationSection
public sealed class SqlCacheDependencySection : System.Configuration.ConfigurationSection
type SqlCacheDependencySection = class
inherit ConfigurationSection
Public NotInheritable Class SqlCacheDependencySection
Inherits ConfigurationSection
- 继承
示例
下面的代码示例演示如何从现有 Web 应用程序的配置文件中获取 SqlCacheDependencySection 对象。
// Get the Web application configuration.
System.Configuration.Configuration webConfig =
WebConfigurationManager.OpenWebConfiguration("/aspnetTest");
// Get the section.
string configPath = "system.web/cache/sqlCacheDependency";
System.Web.Configuration.SqlCacheDependencySection sqlDs =
(System.Web.Configuration.SqlCacheDependencySection)webConfig.GetSection(
configPath);
' Get the Web application configuration.
Dim webConfig As System.Configuration.Configuration = _
WebConfigurationManager.OpenWebConfiguration( _
"/aspnetTest")
' Get the section.
Dim configPath As String = _
"system.web/cache/sqlCacheDependency"
Dim sqlDs _
As System.Web.Configuration.SqlCacheDependencySection = _
CType(webConfig.GetSection(configPath), _
System.Web.Configuration.SqlCacheDependencySection)
注解
这样 SqlCacheDependencySection ,就可以以编程方式访问和修改 sqlCacheDependency 配置节的 cache 元素。
SQL 缓存依赖项允许缓存的数据与原始源同步。 在配置存储在 ASP.NET 应用程序的缓存中的项与特定SQL Server数据库表之间的关系后,SqlCacheDependency 类的实例监视表,以便在表中的项发生更改时,该项会自动从缓存中删除。
此元素中的设置仅影响基于表的对象 SqlCacheDependency 版本。 与 SQL Server 2005 及更高版本一起使用的行级别 SqlCacheDependency 对象不受这些设置的影响。
注释
可以根据SqlCacheDependencySection属性值AllowDefinition为的节属性MachineToApplication定义的限制,将信息写入配置文件的相关节。 在层次结构中不允许的某个级别的配置文件中写入的任何尝试都将导致分析程序生成的错误消息。 但是,可以使用此类在层次结构中的任何级别读取配置信息。
构造函数
| 名称 | 说明 |
|---|---|
| SqlCacheDependencySection() |
初始化 SqlCacheDependencySection 类的新实例。 |