Learn More





Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesDal2 results are empty on live siteDal2 results are empty on live site
New Post
12/12/2014 12:24 AM


I am using the new Dal2 for the business layer in a module I am developing.  The problem I am facing is a difference in results between my test environment ( and my live site, which are both DNN 7.3.4 platform edition.  In my test environment the results return as expected.  In the live site there is some code that gets records from the repository and then dataBinds them to a dropdownlist.  This dropdownlist remains empty even when the cache is cleared.

Here is how I get the records in the page load event of my module control:

                  Dim ctrlViews As New ViewsController
                Dim AllCategories As IEnumerable(Of vw_Category_Hierarchy) = ctrlViews.Get_Categories_By_Hierarchy(Me.PortalId) 
                ddlParentCategory.DataSource = AllCategories

Here is the controller code:

        Public Function Get_Categories_By_Hierarchy(ByVal _PortalId As Integer) As IEnumerable(Of vw_Category_Hierarchy)
                Dim ret As IEnumerable(Of vw_Category_Hierarchy)
                Using ctx As IDataContext = DataContext.Instance()

                    Dim rep As IRepository(Of vw_Category_Hierarchy) = ctx.GetRepository(Of vw_Category_Hierarchy)()
                    ret = rep.Get(_PortalId) '.OrderBy(Function(c) c.FullName)
                End Using
                Return ret
            Catch ex As Exception
                Return Nothing
            End Try            
        End Function

Here is the sql views peta poco class:

<TableName("vw_Category_Hierarchy")> _
    <PrimaryKey("CategoryID", AutoIncrement:=False)> _
    <Cacheable("Category_Hierarchy", CacheItemPriority.Default, 20)> _
    Public Class vw_Category_Hierarchy

        Public Property PortalId As Integer
        Public Property CategoryID As Integer
        Public Property FullName As String
        Public Property CategoryLevel As Integer
    End Class

Even if i set the cache timeout to 0 the records never appear in the drop down.

 The code behind of other pages is working so I don't think it is a namespace issue and there are no errors shown or logged in the event viewer and a try catch with logging wraps all the code in question.

Can someone help me figure out why this works in my test installation but not in my live installation.  

thanks in advance 


New Post
12/12/2014 12:37 AM
Is there a way to run SQL Profiler on your live site to see what SQL is being executed. Is the cache key "Category_Hierarchy" being used by other entity as well. Try removing the entire Cacheable attribute.

Ash Prasad
Director of Engineering
DNN Corp.
New Post
12/12/2014 9:27 AM
Not sure if that single quote mark supposed to appear in front of .OrderBy() but if you say it works in your dev then that is probably not the issue. I am not a VB expert but for the most part code looks ok to me.

ret = rep.Get(_PortalId) '.OrderBy(Function(c) c.FullName)

As Ash suggested run SQL Profiler or what I normally do is just log ret to make sure there is actual data in it. There has to be a good reason why your live site doesn't show any data and this will nicely separate your module code from database and tell you where the problem lies along the pipeline.

But I only do that when I am 100% sure there should be actual data there. Hint. Hint. Again I am sure that you made sure to check that the table contains category data and names match and everyone is happy.

I am sure this doesn't apply in your specific case but when I installed my I included {objectQualifier} which then made aware of its presense on many ocations.
New Post
12/12/2014 2:48 PM
thanks for the reply guys,

I am currently working on it but here are some of the things I can confirm

1. there is data in the DB because the same data is retrieved by a web.API service with no issue (and I manually checked in SSMS). This problem occurs when Dal2 is called in the code behind of one control in my module
2. The single quote just escapes the following code on the line. I escaped the sort lambda just to see if that was the issue.
3. Object qualifier was not used in my local or live installation
4. The cache key Category_Hierarchy is only used once

I will post back as I narrow it down more
New Post
12/12/2014 3:28 PM
Okay, the idea about loggin ret was great.

I put a log to count the results returned here:

ret = rep.Get(_PortalId)

and it returns 0 results, but there are definitely records in the db that are displayed in another control that gets is values from a web service like I mentioned.

I double checked that the scope name and filed name were the same and that the right value was passed in. It was correct

So then I thought that there must be a problem with the view/query that the repository is trying to access. So I ran the query directly in SSMS and it works fine with no errors and returns the correct records. 


Also, i tried removing the cacheable attribute altogether and that did not fix the problem.  

Something is happening in the rep.Get

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesDal2 results are empty on live siteDal2 results are empty on live site

These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
Try Evoq
For Free
Start Free Trial
a Demo
See Evoq Live
Need More Information?