本文整理匯總了C#中System.Web.UI.WebControls.ObjectDataSource.CacheKeyDependency屬性的典型用法代碼示例。如果您正苦於以下問題:C# ObjectDataSource.CacheKeyDependency屬性的具體用法?C# ObjectDataSource.CacheKeyDependency怎麽用?C# ObjectDataSource.CacheKeyDependency使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Web.UI.WebControls.ObjectDataSource
的用法示例。
在下文中一共展示了ObjectDataSource.CacheKeyDependency屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Cache[ObjectDataSource2.CacheKeyDependency] = "CacheExample";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Cache.Remove(ObjectDataSource2.CacheKeyDependency);
Cache[ObjectDataSource2.CacheKeyDependency] = "CacheExample";
DetailsView1.DataBind();
}
示例2: GetFullNamesAndIDs
public class EmployeeLogic
{
public static Array GetFullNamesAndIDs()
{
NorthwindDataContext ndc = new NorthwindDataContext();
var employeeQuery =
from e in ndc.Employees
orderby e.LastName
select new { FullName = e.FirstName + " " + e.LastName, EmployeeID = e.EmployeeID };
return employeeQuery.ToArray();
}
public static Employee GetEmployee(int empID)
{
if (empID < 0)
{
return null;
}
else
{
NorthwindDataContext ndc = new NorthwindDataContext();
var employeeQuery =
from e in ndc.Employees
where e.EmployeeID == empID
select e;
return employeeQuery.Single();
}
}
public static void UpdateEmployeeAddress(Employee originalEmployee, string address, string city, string postalcode)
{
NorthwindDataContext ndc = new NorthwindDataContext();
ndc.Employees.Attach(originalEmployee, false);
originalEmployee.Address = address;
originalEmployee.City = city;
originalEmployee.PostalCode = postalcode;
ndc.SubmitChanges();
}
}