I'm developing a custom predicate inherited from the Predicate class. The goal is surround the output text of a given predicate with a Not clause. Ej: "Not ({FieldComparePredicate})"
But the code, throw an NullReference exception when ToQueryText is called from the internal predicate.
Here is the code:
Imports SD.LLBLGen.Pro.ORMSupportClasses
Public Class NotPredicate
Inherits Predicate
Private m_SourcePredicate As Predicate
Public Sub New(ByVal predicate As Predicate)
MyBase.New()
Me.m_SourcePredicate = predicate
End Sub
Public Overloads Overrides Function ToQueryText(ByRef uniqueMarker As Integer) As String
Return ToQueryText(uniqueMarker, False)
End Function
Public Overloads Overrides Function ToQueryText(ByRef uniqueMarker As Integer, ByVal inHavingClause As Boolean) As String
Me.m_SourcePredicate.DatabaseSpecificCreator = Me.DatabaseSpecificCreator
Return String.Format("NOT ({0})", Me.m_SourcePredicate.ToQueryText(uniqueMarker, inHavingClause))
End Function
End Class
Stack Trace:
ex.StackTrace " at SD.LLBLGen.Pro.DQE.SqlServer.SqlServerSpecificCreator.CreateParameter(IEntityFieldCore field, IFieldPersistenceInfo persistenceInfo, ParameterDirection direction, Object valueToSet)
at SD.LLBLGen.Pro.ORMSupportClasses.FieldCompareValuePredicate.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause)
at SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause)
at Studio.Net.BLL.NotPredicate.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause) in C:\personal\Studio\Net\BLL\LLBLGen\NotPredicate.vb:line 20" String
The runtime version is 2.0.0.0 (March 21st, 2007)
Any help will be welcome, thanks.