internal async Task <IEnumerable <T> > QueryAsync <T>(T instance, Expression <Func <T, IList> > listExpression, Func <T, object[]> idFunc, Sql Sql) { var sql = Sql.SQL; var args = Sql.Arguments; if (EnableAutoSelect) { sql = AutoSelectHelper.AddSelectClause(this, typeof(T), sql); } try { OpenSharedConnectionInternal(); DbCommand cmd = CreateCommand(_sharedConnection, sql, args); DbDataReader r; try { r = await ExecuteReaderHelperAsync(cmd).ConfigureAwait(false); } catch (Exception x) { cmd.Dispose(); OnExceptionInternal(x); throw; } return(listExpression != null?ReadOneToMany(instance, r, cmd, listExpression, idFunc) : Read <T>(typeof(T), instance, r, cmd)); } catch { CloseSharedConnectionInternal(); throw; } }
private async Task <IEnumerable <T> > QueryAsync <T>(T instance, Sql Sql) { var sql = Sql.SQL; var args = Sql.Arguments; if (EnableAutoSelect) { sql = AutoSelectHelper.AddSelectClause(this, typeof(T), sql); } try { OpenSharedConnectionInternal(); using (var cmd = CreateCommand(_sharedConnection, sql, args)) { IDataReader r; try { r = await ExecuteReaderHelperAsync(cmd).ConfigureAwait(false); } catch (Exception x) { OnException(x); throw; } return(Read <T>(typeof(T), instance, r)); } } catch (Exception x) { CloseSharedConnectionInternal(); throw; } }