Reputation: 11
I am migrating a website using Sitecore 6.5 to sitecore 8.1
Below is the code written in sitecore 6.5, I need to change to sitecore 8.1 version. when I used sitecore.analytics 8.1 version, it is showing error. can some help in getting the issue resolved for the below code
public static int GetPageVisits(ID pageId)
{
return DataAdapterManager.Provider.Sql.ReadOne<int>(CommandText, ReadPageViews, new object[] { "currentItemId", pageId.ToString() });
}
below is the error I am getting...
Error 1 'Sitecore.Analytics.DataAccess.DataAdapterProvider' does not contain a definition for 'Sql' and no extension method 'Sql' accepting a first argument of type 'Sitecore.Analytics.DataAccess.DataAdapterProvider' could be found (are you missing a using directive or an assembly reference?)
Upvotes: 1
Views: 151
Reputation: 2422
Sitecore Analytics API changed in xDB, From your code i can see you are trying to get page visits number, For that you can use the following API
VisitStatistics PageStats = Sitecore.Analytics.Testing.TestManager.GetPageStatistics(Guid, DateTime, DateTime)
Guid parameter is the item ID, the 2 DateTime parameters are for the interval time range you want to get the page statistics for.
Upvotes: 1