Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions AspNetCoreWeb/Attributes/SearchableBoolAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using JqueryDataTables.ServerSide.AspNetCoreWeb.Providers;
using System;

namespace JqueryDataTables.ServerSide.AspNetCoreWeb.Attributes
{
[AttributeUsage(AttributeTargets.Property)]
public class SearchableBoolAttribute : SearchableAttribute
{
public SearchableBoolAttribute()
{
ExpressionProvider = new BoolSearchExpressionProvider();
}
}
}
18 changes: 18 additions & 0 deletions AspNetCoreWeb/Providers/BoolSearchExpressionProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Linq.Expressions;

namespace JqueryDataTables.ServerSide.AspNetCoreWeb.Providers
{
public class BoolSearchExpressionProvider : ComparableSearchExpressionProvider
{
public override ConstantExpression GetValue(string input)
{
if (!bool.TryParse(input, out var value))
{
throw new ArgumentException("Invalid search value.");
}

return Expression.Constant(value);
}
}
}