Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var productSpec =
                new ProductMatchesCategory("cat1").Or(new ProductMatchesCategory("cat2"));

            var expr = new ProductEFExpressionVisitor().ExpressionForSpecification(productSpec);

            Console.WriteLine(expr.ToString());

            var fn = expr.Compile();

            Console.WriteLine(fn.Invoke(new EFProduct()
            {
                Category = "cat3"
            }));
            Console.WriteLine(fn.Invoke(new EFProduct()
            {
                Category = "cat1"
            }));
            Console.WriteLine(fn.Invoke(new EFProduct()
            {
                Category = "cat2"
            }));
        }
Exemplo n.º 2
0
        public void Visit(ProductMatchesCategory spec)
        {
            var category = spec.Category;

            Expr = ef => ef.Category == category;
        }