Esempio n. 1
0
 //todo properly handle deletable and expirable
 public void Remove(SpecificationBase <T> specification)
 {
     if (specification == null)
     {
         throw new ArgumentNullException(nameof(specification));
     }
     _dbSet.RemoveRange(_dbSet.Where(specification.ToExpression())
                        .Select(x => x));
 }
Esempio n. 2
0
        public override Expression <Func <T, bool> > ToExpression()
        {
            var leftExpression  = _left.ToExpression();
            var rightExpression = _right.ToExpression();
            var paramExpr       = Expression.Parameter(typeof(T));
            var exprBody        = Expression.OrElse(leftExpression.Body, rightExpression.Body);

            exprBody = (BinaryExpression) new ParameterReplacer(paramExpr).Visit(exprBody);
            var finalExpr = Expression.Lambda <Func <T, bool> >(exprBody, paramExpr);

            return(finalExpr);
        }
Esempio n. 3
0
        public override Expression <Func <T, bool> > ToExpression()
        {
            var specExpression = _spec.ToExpression();

            var paramExpr = Expression.Parameter(typeof(T));
            var exprBody  = Expression.Not(specExpression.Body);

            var visitedExpr = new ParameterReplacer(paramExpr).Visit(exprBody);
            var finalExpr   = Expression.Lambda <Func <T, bool> >(visitedExpr, paramExpr);

            return(finalExpr);
        }
        public override Expression <Func <T, bool> > ToExpression()
        {
            var specExpression = _spec.ToExpression();

            var paramExpr = Expression.Parameter(typeof(T));
            var exprBody  = Expression.Not(specExpression.Body);

            var visitedExpr = new ParameterReplacer(paramExpr).Visit(exprBody);

            if (visitedExpr == null)
            {
                throw new NotSupportedException("ExprBody null");
            }

            var finalExpr = Expression.Lambda <Func <T, bool> >(visitedExpr, paramExpr);

            return(finalExpr);
        }
Esempio n. 5
0
        public override Expression <Func <T, bool> > ToExpression()
        {
            var leftExpression  = _left.ToExpression();
            var rightExpression = _right.ToExpression();
            var paramExpr       = Expression.Parameter(typeof(T));
            var exprBody        = Expression.OrElse(leftExpression.Body, rightExpression.Body);

            exprBody = (BinaryExpression) new ParameterReplacer(paramExpr).Visit(exprBody);

            if (exprBody == null)
            {
                throw new NotSupportedException("ExprBody null");
            }

            var finalExpr = Expression.Lambda <Func <T, bool> >(exprBody, paramExpr);

            return(finalExpr);
        }