sonnemaf / ReflectionIT.Mvc.Paging

ASP.NET Core 3.0 Paging (including filtering and sorting) solution using Entity Framework Core 3.0 and IEnumerable<T>
MIT License
79 stars 37 forks source link

Case insensitive sort expression #26

Open poganytamas opened 5 years ago

poganytamas commented 5 years ago

Your code is using property names as strings for sort expression. This leads to a problem using JavaScript frameworks. Usually when using JSON serializer in MVC core, properties gets camel cased, so eg. ServerId becomes serverId. When I set up for example a vuetify data table, I have to specify header properties: serverId, serverName... When I sort the table, and send back the code, it will search for serverId property, but there is none, there is only ServerId. Of course I could change the JSON serializer, but that would lead to an unusual / weird JavaScript code.

I kindly suggest to change GetPropertyInfo in LinqExtensions.cs so instead of direct name match p.Name == name, it should be case insensitive comparison.