Custom table data source doesn't grab the latest data after update

Kàren Vaganyan asked on January 31, 2018 00:08

I’m working on a custom module and I’m having a strange issue I’m probably overlooking

I have a CMSQueryDataSource that is creating a datasource from a custom query that pulls information from a custom table. I then use that data source and load it into a universal viewer with a hierarchical transformation. In the viewer I have the ability to edit or delete records in that custom table. When I check the DB after making an edit or a delete, I can see the row changed however when the CMSQueryDataSource runs the query again it returns the same datasource as before without any of the changes that happened in the DB. I’m not sure if its some caching issue or something of that sort but I can’t seem to find a way for the CMSQueryDataSource to pull the most recent data every time. Here’s an example of my method:

private void LoadGrid()
    {
        _dataSource.ClearCache();
        _dataSource.QueryName = "custom.pageType.GridListQuery";
        _dataSource.OrderBy = "order by Level asc";
        _dataSource.LoadData(true);
        GroupedDataSource gpd = new GroupedDataSource(_dataSource.DataSource, "ParentID", "Level");
        TransformationInfo ti = TransformationInfoProvider.GetTransformation("custom.pageType.GridListTransformation");
        HierarchicalTransformations transformation = new HierarchicalTransformations("ItemID");
        transformation.LoadFromXML(ti.TransformationHierarchicalXMLDocument);
        _universalViewer.RelationColumnID = "ItemID";
        _universalViewer.Transformations = transformation;
        _universalViewer.DataSource = gpd;
        _universalViewer.DataBind();
    }

Recent Answers


Roman Hutnyk answered on January 31, 2018 09:07 (last edited on January 31, 2018 09:11)

I'm not sure how _dataSource.ClearCache(); works, but looks like this is caching issue. Could you please verify that second load does not actually pulls data from database?

Have you tried to setup cache dependencies for the data source?

0 votesVote for this answer Mark as a Correct answer

Kàren Vaganyan answered on January 31, 2018 16:46

I have a feeling it doesn’t work the way we think it does haha
I’ll give a try to cached dependencies and reply back later

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.