public static bool ExecuteReader(string cmd, DBReaderDelegate func, Transaction trans) { return(new Command(cmd).ExecuteReader(func, trans)); }
public bool ExecuteReader(DBReaderDelegate func) { return(this.ExecuteReader(func, null as Transaction)); }
public static bool ExecuteReader(string cmd, DBReaderDelegate func) { return(new Command(cmd).ExecuteReader(func)); }
public bool ExecuteReader(DBReaderDelegate func, Transaction trans) { Debug.Assert(func != null, "DBReaderDelegate Cannot be NULL"); DbConnection conn = null; DbDataReader r = null; bool err = false; try { DbCommand cmd; if (trans != null) { cmd = this.AsCommonCommand(trans.CurrentConnection.OriConnection, trans.CurrentTransaction); } else { conn = DbProvider.Current.CreateConnection(); conn.Open(); cmd = this.AsCommonCommand(conn, null); } r = cmd.ExecuteReader(); while (r.Read() && func(r)) { ; } return(true); } catch (Exception e) { err = true; if (trans != null) { trans.success = false; } #if DEBUG CommandException ce = new CommandException("ExecuteReader", this, e); Debug.WriteLine(ce); throw ce; #endif return(false); } finally { try { r.Close(); } catch (Exception e) { if (trans != null) { trans.success = false; } #if DEBUG if (!err) { CommandException ce = new CommandException("ExecuteReader", this, e); Debug.WriteLine(ce); throw ce; } #endif } try { if (trans == null) { conn.Close(); } } catch (Exception e) { if (trans != null) { trans.success = false; } #if DEBUG if (!err) { CommandException ce = new CommandException("ExecuteReader", this, e); Debug.WriteLine(ce); throw ce; } #endif } } }
public static bool ExecuteReader(string cmd, DBReaderDelegate func, Transaction trans) { return new Command(cmd).ExecuteReader(func, trans); }
public static bool ExecuteReader(string cmd, DBReaderDelegate func) { return new Command(cmd).ExecuteReader(func); }
public bool ExecuteReader(DBReaderDelegate func) { return this.ExecuteReader(func, null as Transaction); }
public bool ExecuteReader(DBReaderDelegate func, Transaction trans) { Debug.Assert(func != null, "DBReaderDelegate Cannot be NULL"); DbConnection conn = null; DbDataReader r = null; bool err = false; try { DbCommand cmd; if (trans != null) cmd = this.AsCommonCommand(trans.CurrentConnection.OriConnection, trans.CurrentTransaction); else { conn = DbProvider.Current.CreateConnection(); conn.Open(); cmd = this.AsCommonCommand(conn, null); } r = cmd.ExecuteReader(); while (r.Read() && func(r)) ; return true; } catch (Exception e) { err = true; if (trans != null) trans.success = false; #if DEBUG CommandException ce = new CommandException("ExecuteReader", this, e); Debug.WriteLine(ce); throw ce; #endif return false; } finally { try { r.Close(); } catch (Exception e) { if (trans != null) trans.success = false; #if DEBUG if (!err) { CommandException ce = new CommandException("ExecuteReader", this, e); Debug.WriteLine(ce); throw ce; } #endif } try { if (trans == null) conn.Close(); } catch (Exception e) { if (trans != null) trans.success = false; #if DEBUG if (!err) { CommandException ce = new CommandException("ExecuteReader", this, e); Debug.WriteLine(ce); throw ce; } #endif } } }