<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="CacheObjectDataSource" %>
Cached object data source
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CacheObjectDataSource : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Output.Write("objds.GetHashCode() = {0}
", _personObjectDataSource.GetType().GetHashCode());
Response.Output.Write("objds.CacheDuration = {0}
", _personObjectDataSource.CacheDuration);
Response.Output.Write("objds.CacheExpirationPolicy = {0}
", _personObjectDataSource.CacheExpirationPolicy);
Response.Output.Write("objds.SqlCacheDependency = {0}
", _personObjectDataSource.SqlCacheDependency);
Response.Output.Write("objds.Typename = {0}
", _personObjectDataSource.TypeName);
Response.Output.Write("objds.SelctMethod = {0}
", _personObjectDataSource.SelectMethod);
}
}
File: Person.cs
using System;
using System.Data;
using System.Collections.Generic;
using System.Collections;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public class Person
{
private int _age;
private string _name;
private bool _isMarried;
private DateTime _birthDay;
public int Age
{
get { return _age; }
set { _age = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
public bool IsMarried
{
get { return _isMarried; }
set { _isMarried = value; }
}
public DateTime BirthDay
{
get { return _birthDay; }
set { _birthDay = value; }
}
public Person() { }
public Person(int age, string name, bool isMarried, DateTime birthDay)
{
_age = age;
_name = name;
_isMarried = isMarried;
_birthDay = birthDay;
}
}
public static class SampleData
{
public static ICollection GetPeople()
{
List ret = new List();
for (int i = 0; i < 10; i++)
ret.Add(new Person(i + 20, "Person " + i.ToString(), (i % 2) == 0,
DateTime.Now.AddYears(i-40)));
return ret;
}
}