mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.2 KiB
36 lines
1.2 KiB
using System;
|
|
using System.Linq.Expressions;
|
|
|
|
namespace Volo.Abp.Specifications
|
|
{
|
|
/// <summary>
|
|
/// Represents the specification which indicates the semantics opposite to the given specification.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type of the object to which the specification is applied.</typeparam>
|
|
public class NotSpecification<T> : Specification<T>
|
|
{
|
|
private readonly ISpecification<T> _specification;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of <see cref="NotSpecification{T}"/> class.
|
|
/// </summary>
|
|
/// <param name="specification">The specification to be reversed.</param>
|
|
public NotSpecification(ISpecification<T> specification)
|
|
{
|
|
_specification = specification;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the LINQ expression which represents the current specification.
|
|
/// </summary>
|
|
/// <returns>The LINQ expression.</returns>
|
|
public override Expression<Func<T, bool>> ToExpression()
|
|
{
|
|
var expression = _specification.ToExpression();
|
|
return Expression.Lambda<Func<T, bool>>(
|
|
Expression.Not(expression.Body),
|
|
expression.Parameters
|
|
);
|
|
}
|
|
}
|
|
}
|