public override string GenerateSQL(DbCommandTree tree) { DbUpdateCommandTree commandTree = tree as DbUpdateCommandTree; UpdateStatement statement = new UpdateStatement(); //scope.Push(commandTree.Target.VariableName); statement.Target = commandTree.Target.Expression.Accept(this); foreach (DbSetClause setClause in commandTree.SetClauses) { statement.Properties.Add(setClause.Property.Accept(this)); DbExpression value = setClause.Value; SqlFragment valueFragment = value.Accept(this); statement.Values.Add(valueFragment); if (values == null) values = new Dictionary<EdmMember, SqlFragment>(); if (value.ExpressionKind != DbExpressionKind.Null) { EdmMember property = ((DbPropertyExpression)setClause.Property).Property; values.Add(property, valueFragment); } } statement.Where = commandTree.Predicate.Accept(this); if (commandTree.Returning != null) statement.ReturningSelect = GenerateReturningSql(commandTree, commandTree.Returning); return statement.ToString(); }
public override string GenerateSQL(DbCommandTree tree) { DbUpdateCommandTree commandTree = tree as DbUpdateCommandTree; UpdateStatement statement = new UpdateStatement(); //scope.Push(commandTree.Target.VariableName); statement.Target = commandTree.Target.Expression.Accept(this); foreach (DbSetClause setClause in commandTree.SetClauses) { statement.Properties.Add(setClause.Property.Accept(this)); DbExpression value = setClause.Value; SqlFragment valueFragment = value.Accept(this); statement.Values.Add(valueFragment); if (values == null) { values = new Dictionary <EdmMember, SqlFragment>(); } if (value.ExpressionKind != DbExpressionKind.Null) { EdmMember property = ((DbPropertyExpression)setClause.Property).Property; values.Add(property, valueFragment); } } statement.Where = commandTree.Predicate.Accept(this); if (commandTree.Returning != null) { statement.ReturningSelect = GenerateReturningSql(commandTree, commandTree.Returning); } return(statement.ToString()); }