Exception thrown in LLBLGenProDataSource1_PerformGetDbCount

Posts   
 
    
rparkins
User
Posts: 66
Joined: 04-May-2005
# Posted on: 25-Feb-2008 22:35:46   

Hi

Selfservicing LLBLGenProDataSource with livepersistence false. I have a quick search form and a gridview that populates dependant on the search parameters you have. Very simple but causing me an issue as follows:

If I have a clean filter applied to the datasource (ie I have entered no search filters) all is well and I get back 550 rows paged in sizes of 10 and I am happy simple_smile

My issue comes when I apply any filter to the source. PerformDbCount is raising an exception as follows:

[NullReferenceException: Object reference not set to an instance of an object.] SD.LLBLGen.Pro.ORMSupportClasses.DbSpecificCreatorBase.ConvertFieldToRawName(IEntityFieldCore fieldCore, IFieldPersistenceInfo persistenceInfo, String fieldName, String objectAlias, Int32& uniqueMarker, Boolean applyAggregateFunction) +119 SD.LLBLGen.Pro.DQE.SqlServer.SqlServerSpecificCreator.CreateFieldName(IEntityFieldCore fieldCore, IFieldPersistenceInfo persistenceInfo, String fieldName, String objectAlias, Int32& uniqueMarker, Boolean applyAggregateFunction) +69 SD.LLBLGen.Pro.ORMSupportClasses.FieldLikePredicate.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause) +840 SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause) +579 SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause) +579 SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Int32& uniqueMarker) +31 SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Boolean relationsSpecified, Boolean sortClausesSpecified) +2807 SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause) +808 SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateRowCountDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause) +108 SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetDbCount(IEntityFields fields, ITransaction containingTransaction, IPredicate filter, IRelationCollection relations, IGroupByCollection groupByClause, Boolean allowDuplicates) +174 TouchScreenData.Client.DataLayer.TypedListClasses.ContactTypedList.GetDbCount(Boolean allowDuplicates, IPredicateExpression filter, IRelationCollection relations, GroupByCollection groupByClause) in C:\Projects\ASP.NET.2.0\Barton\DataLayer\TypedListClasses\ContactTypedList.cs:303 TouchScreenData.Client.DataLayer.TypedListClasses.ContactTypedList.GetDbCount(Boolean allowDuplicates, IPredicateExpression filter, IRelationCollection relations) in C:\Projects\ASP.NET.2.0\Barton\DataLayer\TypedListClasses\ContactTypedList.cs:280 TouchScreenData.Client.DataLayer.TypedListClasses.ContactTypedList.GetDbCount(Boolean allowDuplicates, IPredicateExpression filter) in C:\Projects\ASP.NET.2.0\Barton\DataLayer\TypedListClasses\ContactTypedList.cs:269 TouchScreenData.Contacts.ContactManager.Count() in C:\Projects\ASP.NET.2.0\Barton\Contacts\ContactManager.cs:95 Controls_Contact_Search_List.LLBLGenProDataSource1_PerformGetDbCount(Object sender, PerformGetDbCountEventArgs e) in c:\Projects\ASP.NET.2.0\Barton\Web\Controls\Contact\Search\List.ascx.cs:79 SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSource.OnPerformDbCount(PerformGetDbCountEventArgs eventArgs) +42 SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView.ExecuteSelectTypedList(Int32 pageSize, Int32 pageNumber, DataSourceSelectArguments arguments) +1020 SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +280 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70 System.Web.UI.WebControls.GridView.DataBind() +4 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82 System.Web.UI.WebControls.GridView.OnPreRender(EventArgs e) +24

My Code is as follows:

protected void LLBLGenProDataSource1_PerformGetDbCount(object sender, SD.LLBLGen.Pro.ORMSupportClasses.PerformGetDbCountEventArgs e) { if (ViewState["ContactCount"] == null) { int count = ContactManager.Count(); e.DbCount = count; LabelItems.Text = count.ToString() + " Contact(s)"; ViewState["ContactCount"] = count; } else { e.DbCount = Convert.ToInt32(ViewState["ContactCount"]); } }

where my manager method for count is:

ContactTypedList list = new ContactTypedList(); return list.GetDbCount(false, cp.GenerateFilter());

The generatefilter() call is from a session object that returnes e the IpredicateExpression object.

I really dont know why this is not working and any help would be appreciated. I hope I havnlt overdone the code examples but hoping someone may find these useful

One thing I have noticed is that the e.containedcollection is always null on within the LLBLGenProDataSource1_PerformGetDbCount and not sure if this is valid for my issue?

Many thanks

and once again a great forum and support. LLblgen rocks

Richard

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Feb-2008 03:56:50   

Looks like a fixed thing. Please post the LLBLGen version and RuntimeLibraries version (http://llblgen.com/TinyForum/Messages.aspx?ThreadID=7720)

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39905
Joined: 17-Aug-2003
# Posted on: 26-Feb-2008 10:18:39   

Also, the routine which produces the filter isn't posted in your post. Could you post that one as well?

Frans Bouma | Lead developer LLBLGen Pro
rparkins
User
Posts: 66
Joined: 04-May-2005
# Posted on: 26-Feb-2008 10:27:04   

Hi Guys

THanks for the quick response. The versions I am using are as follows:

2.5 Final Nov 5th 2007 (I will check for updates)

The code that generates the filter is as follows, and I believe the typedlist has all the relevant fields I use in the filter.

Many thanks

Richard

IPredicateExpression filter = new PredicateExpression();

        //if the searching is disbaled (ie return 0 items). Used as persistance is set true on the datasource
        if (DisableSearch) {
            filter.AddWithAnd(OrganisationFields.OId == 0);
            return filter;
        }

        if (County != String.Empty) {
            filter.Add(new FieldLikePredicate(LocationFields.LCounty, null, County + "%"));
        }

        if (Surname != String.Empty) {
            filter.Add(new FieldLikePredicate(ContactFields.CSurname, null, Surname + "%"));
        }

        if (Firstname != String.Empty) {
            filter.Add(new FieldLikePredicate(ContactFields.CFirstname, null, Firstname + "%"));
        }

        if (Postcode != String.Empty) {
            filter.Add(new FieldLikePredicate(LocationFields.LPostcode, null, Postcode + "%"));
        }

        if (Organisation > 0) {
            filter.Add(new FieldLikePredicate(OrganisationFields.OName, null, Organisation + "%"));
        }

        return filter;
Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Feb-2008 10:44:30   

It appears to me that you are using the SelfServicing model, right?

Yet you are using Adapter overloads for the FieldLikePredicate() SlefServicing overloads should be like:

filter.Add(new FieldLikePredicate(LocationFields.LCounty, County + "%"));
rparkins
User
Posts: 66
Joined: 04-May-2005
# Posted on: 26-Feb-2008 10:49:04   

You are right, thanks for spot, I also upgraded as well to be sure.

Thanks for the help, flushed

Rich

Walaa wrote:

It appears to me that you are using the SelfServicing model, right?

Yet you are using Adapter overloads for the FieldLikePredicate() SlefServicing overloads should be like:

filter.Add(new FieldLikePredicate(LocationFields.LCounty, County + "%"));