public T RunScalarFunctionResult <T>(string ScalarFunctionName, T DefaultValue, out bool Result, params IDataParameter[] parameters) { Result = false; DBOpenResults firstConnectionState = DBOpenResults.Failed; try { firstConnectionState = Open(); if (!IsConnectionOpen && firstConnectionState == DBOpenResults.Failed) { return(DefaultValue); } var reader = RunStatement(BuildScalarFunctionStatement(ScalarFunctionName, parameters), parameters, out Result); while (reader.Read()) { return((T)reader.GetValue(0)); } DataReaderEnumerator.HandleDataReader(reader); } catch (System.Exception e) { SetLastExceptionError(e); Result = false; } finally { Close(firstConnectionState); } return(DefaultValue); }
public void WrapDataReader(DbDataReader reader, Action <DbDataReader> action) { try { if (action != null) { action(reader); } } catch (Exception e) { throw e; } finally { DataReaderEnumerator.HandleDataReader(reader); } }