Ejemplo n.º 1
0
        public IDbScalar <TModel, TReturnType> Where(Expression <Func <TModel, object> > expression)
        {
            _whereExpressionVisitor = new WhereExpressionVisitor().Visit(expression);
            _whereClause            = string.Format(_dbProvider.Dialect.Where, _whereExpressionVisitor.WhereExpression);
            _parameters             = _whereExpressionVisitor.Parameters;

            return(this);
        }
Ejemplo n.º 2
0
        public Task Delete <TModel>(Expression <Func <TModel, bool> > expression) where TModel : class, new()
        {
            var visitor = new WhereExpressionVisitor().Visit(expression);

            // this is a hard delete. soft deletes will happen in the repository layer.
            var tableName   = typeof(TModel).BuildTableName();
            var whereClause = string.Format(Dialect.Where, visitor.WhereExpression);
            var commandText = string.Format(Dialect.DeleteFrom, tableName, whereClause);

            return(ExecuteNonQuery(commandText, visitor.Parameters));
        }
Ejemplo n.º 3
0
        public IDbQuery <TModel> Where(Expression <Func <TModel, bool> > expression)
        {
            _whereExpressionVisitor = new WhereExpressionVisitor(Parameters).Visit(expression);
            Parameters = _whereExpressionVisitor.Parameters;

            if (string.IsNullOrEmpty(WhereClause))
            {
                WhereClause = string.Format(DbProvider.Dialect.Where, _whereExpressionVisitor.WhereExpression);
            }
            else
            {
                WhereClause += " AND " + _whereExpressionVisitor.WhereExpression;
            }
            return(this);
        }