Skip to content
Open
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
26 changes: 11 additions & 15 deletions NExtends/Primitives/Expressions/Expression.extensions.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
using System;
using System.Linq;
using System.Linq.Expressions;

namespace NExtends.Primitives.Expressions
{
public static class ExpressionExtensions
{
/// <summary>
/// http://stackoverflow.com/questions/13705394/how-to-make-a-predicatebuilder-not
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="expr"></param>
/// <returns></returns>
public static Expression<Func<T, bool>> Not<T>(this Expression<Func<T, bool>> expr)
{
return Expression.Lambda<Func<T, bool>>
(Expression.Not(Expression.Invoke(expr, expr.Parameters.Cast<Expression>())), expr.Parameters);
}
}
public static class ExpressionExtensions
{
/// <summary>
/// http://stackoverflow.com/questions/13705394/how-to-make-a-predicatebuilder-not
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="expr"></param>
/// <returns></returns>
public static Expression<Func<T, bool>> Not<T>(this Expression<Func<T, bool>> expression)
=> Expression.Lambda<Func<T, bool>>(Expression.Not(expression.Body), expression.Parameters);
}
}