ods通用缓存和排序

时间:2012-05-18 17:54:32

标签: c# asp.net objectdatasource

首先,我想说,唉!!

Picking off where this thread left off

基本上,线程无法在启用缓存的情况下对通用列表进行排序。我尝试了一些回复的组合,但没有运气。好像我很亲密,但到目前为止......

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
    //What goes in this area?
    CheckExpiredCacheKey(argRefresh);
    ObjectDataSource1.SelectParameters["sortBy"].DefaultValue = string.Format("{0} {1}", e.SortExpression, e.SortDirection == SortDirection.Ascending ? "ASC" : "DESC");                     
    e.Cancel = true;
}

public void CheckExpiredCacheKey(string ckey)
{
    if (Cache[ckey] == null)
        Cache[ckey] = new object(); //Set Cache key which will b used to manually expire ODS cache     

    if (!IsPostBack && Request.QueryString["refresh"] == "1")//check refresh flag
    {
        //Cache.Remove(ckey);//NOT NEEDED: use the following instead
        Cache[ckey] = new object();// Needed otherwise it'll call Grid-populate twice
    }
}

这是Select方法,当尝试这种排序通用列表和缓存的方式时,sortBy字符串总是空白的?

[DataObject(true)]
public class BusinessLogic
{
    [DataObjectMethod(DataObjectMethodType.Select, true)]
    public static List<Customer> GetCustomers(int financeId, int startIndex, int pageSize, string sortBy)
    {
        return DataAccess.GetCustomers(financeId, startIndex, pageSize, sortBy);
    }

0 个答案:

没有答案