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
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