public BeginTransaction ( ) : |
||
리턴 |
/// <summary> /// Returns the translated T-SQL script. For testing only. /// </summary> /// <returns>The translated T-SQL script</returns> internal string GetTsqlQuery() { var sr = new StringReader(CommandText); var parser = new GraphViewParser(); IList <ParseError> errors; var script = parser.Parse(sr, out errors) as WSqlScript; if (errors.Count > 0) { throw new SyntaxErrorException(errors); } if (errors.Count > 0) { throw new SyntaxErrorException(errors); } // Translation and Check CheckInvisibleColumn using (SqlTransaction tx = GraphViewConnection.BeginTransaction()) { var visitor = new TranslateMatchClauseVisitor(tx); visitor.Invoke(script); return(script.ToString()); } }
public int ExecuteNonQuery() { try { if (CommandType == CommandType.StoredProcedure) { if (Tx != null) { Command.Transaction = Tx; } Command.CommandText = CommandText; return(Command.ExecuteNonQuery()); } var sr = new StringReader(CommandText); var parser = new GraphViewParser(); IList <ParseError> errors; var script = parser.Parse(sr, out errors) as WSqlScript; if (errors.Count > 0) { throw new SyntaxErrorException(errors); } bool externalTransaction = true; if (Tx == null) { externalTransaction = false; Tx = GraphViewConnection.BeginTransaction(); } // Translation var modVisitor = new TranslateDataModificationVisitor(Tx); modVisitor.Invoke(script); var matchVisitor = new TranslateMatchClauseVisitor(Tx); matchVisitor.Invoke(script); Command.CommandText = script.ToString(); Command.Transaction = Tx; #if DEBUG // For debugging OutputResult(CommandText, Command.CommandText); #endif int res = Command.ExecuteNonQuery(); if (!externalTransaction) { Tx.Commit(); Tx.Dispose(); Tx = null; } return(res); } catch (SqlException e) { throw new SqlExecutionException("An error occurred when executing the query", e); } }