Hi all,
In read through the forums and it was recommended to use the GetDBCount function to retrieve a COUNT ona table.
Here is my query code:
Public Shared Function GetCount(ByVal MaxRank As Integer) As Integer
Using _Adapter As New DataAccessAdapter()
Dim _DBCount As Integer = _Adapter.GetDbCount(New HelperClasses.EntityCollection(Of LeaderboardEntity), Nothing)
If _DBCount >= MaxRank Then
Return MaxRank
Else
Return _DBCount
End If
End Using
End Function
I like to do a count on a flat table (i.e. no relations, no filters, etc).
I am getting an exception on the line
Dim _DBCount As Integer = _Adapter.GetDbCount(New HelperClasses.EntityCollection(Of LeaderboardEntity), Nothing)
Any ideas why I get the following error:
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="SD.LLBLGen.Pro.ORMSupportClasses.NET20"
StackTrace:
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.GetDbCount(IEntityCollection2 collection, IRelationPredicateBucket filter)
at CBO.BusinessLayer.LeaderBoard.GetCount(Int32 MaxRank) in D:\Personal Programming Projects\DateOMatic\CBO.BusinessLayer\LeaderBoard.vb:line 21
at LeaderBoard.LeaderBoardDataSource_PerformGetDbCount(Object sender, PerformGetDbCountEventArgs2 e) in D:\Personal Programming Projects\DateOMatic\Web Application\LeaderBoard.aspx.vb:line 33
at SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSource2.OnPerformDbCount(PerformGetDbCountEventArgs2 eventArgs)
at SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView2.ExecuteSelectEntityCollection(Int32 pageSize, Int32 pageNumber, DataSourceSelectArguments arguments)
at SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView2.ExecuteSelect(DataSourceSelectArguments arguments)
at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at System.Web.UI.WebControls.GridView.DataBind()
at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()
at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Seems like something within ORMSupportClasses is exceptioning?