Created
November 23, 2021 21:58
-
-
Save thdotnet/9898843591b1f7633b25ebf0fb948671 to your computer and use it in GitHub Desktop.
Generic Specification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq.Expressions; | |
namespace Sample | |
{ | |
public class GenericSpecification<T> | |
{ | |
public Expression<Func<T, bool>> Expression { get; } | |
public GenericSpecification(Expression<T, bool> expression) | |
{ | |
Expression = expression; | |
} | |
public bool IsSatisfiedBy(T entity) | |
{ | |
return Expression.Compile().Invoke(entity); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment