Kusumoto / PrimeNG.TableFilter

Helper for use the PrimeNG table load lazy filter in backend use LINQ to Entity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enums filtering support

duhapunk opened this issue · comments

Hello again! I noticed that your lib doesn't support enums. I fixed it like this:

if (property.PropertyType.IsEnum)
{
     Enum.TryParse(property.PropertyType, value.ToString(), true, out var result);
     return result; // additional checks required
}

Works for me, @Kusumoto Could you release the fix?

Works for me, @Kusumoto Could you release the fix?

I already try, it work but TryParse method just work for .NET Standard 2.0 only.

This is the major change because after support this I'll obsolete .NET Framework support.

Did you try "manual" TryParse ? Something like this

try
{
   var val = Enum.Parse(property.PropertyType, value.ToString(), true);
   var result = Convert.ChangeType(val, property.PropertyType);
   // additional checks required
   return result;
}
catch (Exception ex)
{
   // do some stuff
   return null;
}

Enum filtering would be great, if this could be incorporated :)