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