te SqlConnection GetConnection()
{
return new SqlConnection(this._connectionString);
}
private SqlCommand GetSelectCommand(string key)
{
SqlConnection conn = this.GetConnection();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select Flag from dbo.CacheDependency where CacheKey=@CacheKey";
SqlParameter sqlParam = cmd.Parameters.Add("@CacheKey", SqlDbType.VarChar, 50);
sqlParam.Value = key;
return cmd;
}
private SqlCommand GetUpdateCommand(string key)
{
SqlConnection conn = this.GetConnection();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = @"
if exists (select 1 from dbo.CacheDependency where CacheKey=@CacheKey)
update dbo.CacheDependency set Flag=case when isnull(flag,0)=0 then 1 else 1 end where CacheKey=@CacheKey
else
insert into dbo.CacheDependency (CacheKey,Flag)
values (@CacheKey, 0)
";
SqlParameter sqlParam = cmd.Parameters.Add("@CacheKey", SqlDbType.VarChar, 50);
sqlParam.Value = key;
&nbs