當前位置: 首頁>>代碼示例>>C#>>正文


C# ObjectDataSource.CacheKeyDependency屬性代碼示例

本文整理匯總了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();
}
開發者ID:.NET開發者,項目名稱:System.Web.UI.WebControls,代碼行數:13,代碼來源:ObjectDataSource.CacheKeyDependency

示例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();
    }
}
開發者ID:.NET開發者,項目名稱:System.Web.UI.WebControls,代碼行數:42,代碼來源:ObjectDataSource.CacheKeyDependency


注:本文中的System.Web.UI.WebControls.ObjectDataSource.CacheKeyDependency屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。