Skip to content
Closed
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
23 changes: 22 additions & 1 deletion src/JsonApiDotNetCore/Extensions/IQueryableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,28 @@ private static Expression GetFilterExpressionLambda(Expression left, Expression
body = Expression.GreaterThanOrEqual(left, right);
break;
case FilterOperation.like:
body = Expression.Call(left, "Contains", null, right);
case FilterOperation.notlike:
body = Expression.Call(left, nameof(string.Contains), null, right);
if(operation== FilterOperation.notlike)
{
body = Expression.Not(body);
}
break;
case FilterOperation.sw:
case FilterOperation.notsw:
body = Expression.Call(left, nameof(string.StartsWith), null, right);
if (operation == FilterOperation.notsw)
{
body = Expression.Not(body);
}
break;
case FilterOperation.ew:
case FilterOperation.notew:
body = Expression.Call(left, nameof(string.EndsWith), null, right);
if (operation == FilterOperation.notew)
{
body = Expression.Not(body);
}
break;
// {model.Id != 1}
case FilterOperation.ne:
Expand Down
7 changes: 6 additions & 1 deletion src/JsonApiDotNetCore/Internal/Query/FilterOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public enum FilterOperation
@in = 7, // prefix with @ to use keyword
nin = 8,
isnull = 9,
isnotnull = 10
isnotnull = 10,
notlike = 11,
sw = 12, //start with
notsw = 13, //doesn't start with
ew = 14, // end with,
notew = 15 // doesn't end with
}
}