Kusumoto / PrimeNG.TableFilter

Helper for use the PrimeNG table load lazy filter in backend use LINQ to Entity
MIT License
17 stars 10 forks source link

Filtering with nullable properties #21

Closed crega closed 2 years ago

crega commented 2 years ago

Hello we have an issue (exception) while filtering dataset. We have an IQueryable which some properties from database , and some of them are typeint? (nullable integer)

Those propeties are part of filterable columns in prime ng table. When we send TableFilterModel object to our backend containing filter value 1 (integer) matchMode equals

for example { filters: { num1Nullable: { value: 1, matchMode: \"equals\" } } , first: 0, globalFilter: null, multiSortMeta: undefined, rows: 10, sortField: \"Num1\",sortOrder: -1 } where num1Nullable is of type int? we get an exception thrown

Expression.Constant(Object value, Type type) LinqOperator1.AddFilterProperty(String propertyName, Object propertyValue, String extensionMethod, OperatorEnumeration operatorAction, Boolean isNegation) line 57 TableFilterManager1.BaseFilterDataSet(String key, TableFilterContext value, OperatorEnumeration operatorAction) line 104 TableFilterManager1.FilterDataSet(String key, TableFilterContext value) line 70 PrimeNGTableFilterExtension.PrimengTableFilter[T](IQueryable1 dataSet, TableFilterModel tableFilterPayload, Int32& totalRecord) line 43

Indicating that var propertyConstant = Expression.Constant(castValue, propertyType); threw argument excpetion.

Can you help us ?

Kusumoto commented 2 years ago

Hi, thank you for report the issue

I will release bug fix in next version.

crega commented 2 years ago

Hi. I have already fixed it for our team, using same pattern as for DateTime? You have provided. Also I have written many tests, will post it on Monday or Tuesday.