internal override SqlStatement VisitDelete(SqlDelete sd) { SqlScope save = this.CurrentScope; this.CurrentScope = new SqlScope(sd, this.CurrentScope.ContainingScope); base.VisitDelete(sd); this.CurrentScope = save; return sd; }
internal virtual SqlStatement VisitDelete(SqlDelete delete) { delete.Select = this.VisitSequence(delete.Select); return delete; }
private SqlStatement VisitDelete(Expression item, LambdaExpression check) { if(item == null) { throw Error.ArgumentNull("item"); } bool saveAllowDeferred = _allowDeferred; _allowDeferred = false; try { MetaTable metaTable = _services.Model.GetTable(item.Type); Expression source = _services.Context.GetTable(metaTable.RowType.Type).Expression; Type rowType = metaTable.RowType.Type; // construct identity predicate based on supplied item ParameterExpression p = Expression.Parameter(rowType, "p"); LambdaExpression idPredicate = Expression.Lambda(Expression.Equal(p, item), p); // combine predicate and check expression into single find predicate LambdaExpression findPredicate = idPredicate; if(check != null) { findPredicate = Expression.Lambda(Expression.And(Expression.Invoke(findPredicate, p), Expression.Invoke(check, p)), p); } Expression seq = Expression.Call(typeof(Enumerable), "Where", new Type[] { rowType }, source, findPredicate); SqlSelect ss = new RetypeCheckClause().VisitSelect(this.VisitSequence(seq)); _allowDeferred = saveAllowDeferred; SqlDelete sd = new SqlDelete(ss, source); return sd; } finally { _allowDeferred = saveAllowDeferred; } }
internal override SqlStatement VisitDelete(SqlDelete sd) { _commandStringBuilder.Append("DELETE FROM "); _suppressedAliases.Add(sd.Select.From); this.Visit(sd.Select.From); if(sd.Select.Where != null) { _commandStringBuilder.Append(" WHERE "); this.Visit(sd.Select.Where); } _suppressedAliases.Remove(sd.Select.From); return sd; }
internal override SqlStatement VisitDelete(SqlDelete sd) { return new SqlDelete((SqlSelect)this.Visit(sd.Select), sd.SourceExpression); }
internal override SqlStatement VisitDelete(SqlDelete sd) { bool saveTop = this.topLevel; this.topLevel = false; base.VisitDelete(sd); this.topLevel = saveTop; return sd; }