FieldCompareNullPredicate with negate = true doesn't work as expected

Posts   
 
    
khelb
User
Posts: 11
Joined: 27-Jun-2006
# Posted on: 02-Aug-2006 16:51:26   

Hello,

I'm using an entityview to fill a DataTable using a filter FieldCompareRange() and FieldCompareNull ( negate = true).

But this doesn't seem to work (actually the negate doesn't work). The debug visualizer shows me the correct query text but the negate doesn't seems to be handled when filling the datatable.

this is my code...


        IPredicateExpression filter = new PredicateExpression( );
        //this adds the FieldCompareRangePredicate
        filter.Add(getFiltersForTypesExcluding(strNodeTypeCategory));
        // tried also with the extra parameter true in the constructor
        IPredicate filter2 =
            new FieldCompareNullPredicate(AlleCategorieMeetpuntTypeInstallatieTypeVoorJobsFields.CategorieNr);
        filter2.Negate = true;
        filter.Add(filter2);
        
        ISortExpression sorter = new SortExpression();
        sorter.Add(AlleCategorieMeetpuntTypeInstallatieTypeVoorJobsFields.CategorieNaam | SortOperator.Ascending);
        filterListView.Sorter = sorter;
        
        List<IEntityPropertyProjector> projectors = new List<IEntityPropertyProjector>();
        projectors.Add( new EntityPropertyProjector(AlleCategorieMeetpuntTypeInstallatieTypeVoorJobsFields.CategorieNr
                                                    , "CategoryNr"));
        projectors.Add( new EntityPropertyProjector(AlleCategorieMeetpuntTypeInstallatieTypeVoorJobsFields.CategorieNaam
                                                    , "CategoryName"));
        
        filterListView.CreateProjection( projectors, dtCategories, false, filter);

        // it seems as if the negate flag isn't handled when processing this filter

I've tried my luck a bit and took a look in the source code:

In: **FieldCompareNullPredicate.cs ** in method InterpretPredicate there was no code for handling the Negate property of the predicate. I've added the 2 lines below and now it works for me.


 protected override bool InterpretPredicate( IEntityCore entity )
{
            if( _field == null )
            {
                return false;
            }

            object fieldValue = ((IEntityFieldCoreInterpret)_field).GetValue( entity );
                                                // start code add
            if( Negate )
                return (fieldValue != DBNull.Value);
                                                //end code add
            return (fieldValue == DBNull.Value);
}

I'm not sure this the right solution (I've quickly ran through the code so I'm not getting the whole picture).

Kind regards,

C+++

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 02-Aug-2006 17:09:32   

You could also check the generated sql query to see if it is/was genearetd as expected or not.

And for this you should turn the DQE tracing ON, please refer to LLBLGen Pro manual "Using the generated code -> Troubleshooting and debugging"

khelb
User
Posts: 11
Joined: 27-Jun-2006
# Posted on: 02-Aug-2006 17:15:22   

You could also check the generated sql query to see if it is/was genearetd as expected or not.

The generated sql query is generated as expected. [Edit] I'm using the debugvisualizer for checking the generated 'pseudo' sql code [/Edit] And I've tested it manually.

But the sql isn't used as I'm projecting a entityview (Selfservicing) into a datatable, in that case no real sql is used (If I'm not mistaken)

The DQE doesn't show anything as for same reason above.

Kind regards,

C+++

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 02-Aug-2006 18:58:15   

You're 100% correct. Fixed in next build simple_smile

Frans Bouma | Lead developer LLBLGen Pro
khelb
User
Posts: 11
Joined: 27-Jun-2006
# Posted on: 02-Aug-2006 21:07:30   

Otis wrote:

You're 100% correct. Fixed in next build simple_smile

thanks, I'm glad I could help. smile .

PS: Are you gonna look at all the FieldCompareXXXPredicates? Appearantly they have the same issue confused

oh ja, thanks for the fine product wink

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 02-Aug-2006 21:23:33   

You're right!

How sloppy. I'll fix that as well simple_smile

Frans Bouma | Lead developer LLBLGen Pro