Skip to content

Commit 7ae926a

Browse files
committed
Consider null string in filters
1 parent d71e226 commit 7ae926a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Mvc.JQuery.Datatables/TypeFilters.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,12 @@ public static string StringFilter(string q, string columnname, Type columntype,
8181
{
8282
if (q.StartsWith("^"))
8383
{
84-
return columnname + ".ToLower().StartsWith(\"" + q.ToLower().Replace("\"", "\"\"") + "\")";
84+
return "(!string.IsNullOrEmpty(" + columnname + ") && " + columnname + ".ToLower().StartsWith(\"" + q.ToLower().Replace("\"", "\"\"") + "\"))";
8585
}
8686
else
8787
{
88-
return columnname + ".ToLower().Contains(\"" + q.ToLower().Replace("\"", "\"\"") + "\")";
88+
return "(!string.IsNullOrEmpty(" + columnname + ") && " + columnname + ".ToLower().Contains(\"" + q.ToLower().Replace("\"", "\"\"") + "\"))";
8989
}
9090
}
91-
9291
}
9392
}

0 commit comments

Comments
 (0)