- Home
- LLBLGen Pro
- LLBLGen Pro Runtime Framework
DbFunctionCall for PredicateExpression
Joined: 02-Jul-2015
I put together a predicate expression using some nested DbFunctionCalls based on syntax I found here: http://www.llblgen.com/documentation/4.2/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/gencode_dbfunctioncall.htm.
The predicate build and adding it to the RelationPredicateBucket runs without an error. But when I get to the FetchEntityCollection I get this error: ** "An exception of type 'System.NullReferenceException' occurred in SD.LLBLGen.pro.ORMSupportClasses.dll but was not handled in user code."**
The purpose is to filter results to only those where the TableId (alphanumeric unique identifier) is longer than 3 characters. Here is the code that calls DbFunctionCall to build the expression:
Dim bucket As New RelationPredicateBucket Dim LengthFilter As IPredicate Dim nLength As Integer = 4 LengthFilter = New EntityField("IdLength", New DbFunctionCall("LENGTH", New Object() {New DbFunctionCall("RTRIM", New Object() {New DbFunctionCall("LTRIM", New Object() {TableFields.TableId})})})) >= nLength bucket.PredicateExpression.Add(LengthFilter)
At first I thought I was messing up the nested function calls. So I took it down to just the LENGTH call:
LengthFilter = (New EntityField("IdLength", New DbFunctionCall("LENGTH", New Object() {TableFields.TableId})) > nLength)
Same result.
There are other predicates being added to the bucket - just without DbFunctionCalls. If I comment out the "bucket.predicateExpression.Add(LengthFilter)" line above, there is no error. So the other predicates and the data pull execution work fine without this new predicate expression.
Is there something wrong with my syntax? Is there an alternate way of accomplishing this same thing?
Thanks for your help.
-Mike O.
Joined: 02-Jul-2015
Stack trace...
SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(bool inHavingClause) Line 226 C#
SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText() Line 179 C#
SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase. AppendWhereClause(SD.LLBLGen.Pro.ORMSupportClasses.IPredicate filter, SD.LLBLGen.Pro.ORMSupportClasses.QueryFragments destination, SD.LLBLGen.Pro.ORMSupportClasses.IQuery query) Line 1591 C#
SD.LLBLGen.Pro.DQE.DataDirectDB2.dll!SD.LLBLGen.Pro.DQE.DB2.DynamicQueryEngine.CreateSelectDQ( SD.LLBLGen.Pro.ORMSupportClasses.IEntityFieldCore[] selectList, SD.LLBLGen.Pro.ORMSupportClasses.IFieldPersistenceInfo[] fieldsPersistenceInfo, SD.LLBLGen.Pro.ORMSupportClasses.IRetrievalQuery query, SD.LLBLGen.Pro.ORMSupportClasses.IPredicate selectFilter, long maxNumberOfItemsToReturn, SD.LLBLGen.Pro.ORMSupportClasses.ISortExpression sortClauses, SD.LLBLGen.Pro.ORMSupportClasses.IRelationCollection relationsToWalk, bool allowDuplicates, SD.LLBLGen.Pro.ORMSupportClasses.IGroupByCollection groupByClause, bool relationsSpecified, bool sortClausesSpecified) Line 350 C#
SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ( SD.LLBLGen.Pro.ORMSupportClasses.IEntityFieldCore[] selectList, SD.LLBLGen.Pro.ORMSupportClasses.IFieldPersistenceInfo[] fieldsPersistenceInfo, System.Data.Common.DbConnection connectionToUse, SD.LLBLGen.Pro.ORMSupportClasses.IPredicate selectFilter, long maxNumberOfItemsToReturn, SD.LLBLGen.Pro.ORMSupportClasses.ISortExpression sortClauses, SD.LLBLGen.Pro.ORMSupportClasses.IRelationCollection relationsToWalk, bool allowDuplicates, SD.LLBLGen.Pro.ORMSupportClasses.IGroupByCollection groupByClause) Line 1134 C#
SD.LLBLGen.Pro.DQE.DataDirectDB2.dll!SD.LLBLGen.Pro.DQE.DB2.DynamicQueryEngine.CreatePagingSelectDQ( SD.LLBLGen.Pro.ORMSupportClasses.IEntityFieldCore[] selectList, SD.LLBLGen.Pro.ORMSupportClasses.IFieldPersistenceInfo[] fieldsPersistenceInfo, System.Data.Common.DbConnection connectionToUse, SD.LLBLGen.Pro.ORMSupportClasses.IPredicate selectFilter, int rowsToSkip, int rowsToTake, SD.LLBLGen.Pro.ORMSupportClasses.ISortExpression sortClauses, SD.LLBLGen.Pro.ORMSupportClasses.IRelationCollection relationsToWalk, bool allowDuplicates, SD.LLBLGen.Pro.ORMSupportClasses.IGroupByCollection groupByClause) Line 417 C#
SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ( SD.LLBLGen.Pro.ORMSupportClasses.IEntityFieldCore[] selectList, SD.LLBLGen.Pro.ORMSupportClasses.IFieldPersistenceInfo[] fieldsPersistenceInfo, System.Data.Common.DbConnection connectionToUse, SD.LLBLGen.Pro.ORMSupportClasses.IPredicate selectFilter, int rowsToSkip, int rowsToTake, SD.LLBLGen.Pro.ORMSupportClasses.ISortExpression sortClauses, SD.LLBLGen.Pro.ORMSupportClasses.IRelationCollection relationsToWalk, bool allowDuplicates, SD.LLBLGen.Pro.ORMSupportClasses.IGroupByCollection groupByClause) Line 1206 C#
SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.CreateSelectDQ( SD.LLBLGen.Pro.ORMSupportClasses.QueryParameters parameters) Line 4169 C#
SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore. FetchEntityCollectionInternal(SD.LLBLGen.Pro.ORMSupportClasses.QueryParameters parameters) Line 4267 C#
SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore .FetchEntityCollection(SD.LLBLGen.Pro.ORMSupportClasses.QueryParameters parameters) Line 2208 C#
[External Code]
SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection.AnonymousMethod__d5() Line 224 C#
SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase. ExecuteWithActiveRecoveryStrategy(System.Action toExecute) Line 517 C#
SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase. FetchEntityCollection(SD.LLBLGen.Pro.ORMSupportClasses.QueryParameters parameters) Line 225 C#
SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore. FetchEntityCollection(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCollection2 collectionToFill, SD.LLBLGen.Pro.ORMSupportClasses.IRelationPredicateBucket filterBucket, int maxNumberOfItemsToReturn, SD.LLBLGen.Pro.ORMSupportClasses.ISortExpression sortClauses, SD.LLBLGen.Pro.ORMSupportClasses.IPrefetchPath2 prefetchPath, SD.LLBLGen.Pro.ORMSupportClasses.ExcludeIncludeFieldsList excludedIncludedFields, int pageNumber, int pageSize) Line 2180 C#
XXX.BusinessLogic.dll!XXX.BusinessLogic.EntityBizLogicBase.FetchCollection(Of XXX.DB2.DAL.EntityClasses.ThirdPartyEntity)(SD.LLBLGen.Pro.ORMSupportClasses.IRelationPredicateBucket filterBucket, Integer maxNumberOfItemsToReturn, SD.LLBLGen.Pro.ORMSupportClasses.ISortExpression sorter, SD.LLBLGen.Pro.ORMSupportClasses.IPrefetchPath2 prefetch, SD.LLBLGen.Pro.ORMSupportClasses.ExcludeIncludeFieldsList fieldsList, Integer pageNumber, Integer pageSize) Line 223 Basic
XXX.BusinessLogic.dll!XXX.BusinessLogic.EntityBizLogicBase.FetchCollection(Of XXX.DB2.DAL.EntityClasses.ThirdPartyEntity)(SD.LLBLGen.Pro.ORMSupportClasses.IRelationPredicateBucket filterBucket, SD.LLBLGen.Pro.ORMSupportClasses.ISortExpression sorter) Line 175 Basic
XXX.BusinessLogic.dll!XXX.BusinessLogic.ThirdPartyEntityBL.FetchSortedCollection(SD.LLBLGen.Pro.ORMSupportClasses. IRelationPredicateBucket filterBucket) Line 126 Basic
XXX.Web.UI.dll!XXX.Web.UI.SearchServices.GetThirdPartyItems(SD.LLBLGen.Pro.ORMSupportClasses. RelationPredicateBucket bucket, Integer rowsToFetch) Line 461 Basic
XXX.Web.UI.dll!XXX.Web.UI.SearchServices.GetFilteredFIPSItems(Telerik.Web.UI.RadComboBoxContext context) Line 236 Basic
Joined: 02-Jul-2015
daelmo,
Switching to EntityField2 worked! Thank you.
I have no idea what the Adapter TemplateSet is or what the difference between EntityField and EntityField2 is. Didn't have any luck finding them in the online documentation.
For future reference, could you point me in the right direction to learn when these should be used and what the Adapter TemplateSet is?
Thanks.
-Mike
Joined: 17-Aug-2003