System.Data.Common.DbCommand.ExecuteReader()

Here are the examples of the csharp api class System.Data.Common.DbCommand.ExecuteReader() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

1. Example

Project: encog-dotnet-core
Source File: SQLCODEC.cs
View license
public void PrepareRead()
        {
            _results = _statement.ExecuteReader();
        }

2. Example

Project: System.Data.SQLite
Source File: SQLiteCommand.cs
View license
public new SQLiteDataReader ExecuteReader()
		{
			return (SQLiteDataReader) base.ExecuteReader();
		}

3. Example

View license
public new DbDataReaderRedundant ExecuteReader()
        {
            return (DbDataReaderRedundant)base.ExecuteReader();
        }

4. Example

Project: sqlhelper2
Source File: CommandDatabase.cs
View license
public bool HasRow(string sql, object parameters) {
            Command.CommandType = CommandType.Text;
            Command.CommandText = sql;
            Command.SetParameters(parameters);

            using (var dr = Command.ExecuteReader()) {
                return dr.HasRows;
            }
        }

5. Example

Project: ALinq
Source File: AccessDbConnection.cs
View license
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
        {
            var reader = source.ExecuteReader();
            return new AccessDbReader(reader);
        }

6. Example

View license
public override DbDataReader GetResultSet(DbCommand statement)
		{
			return statement.ExecuteReader();
		}

7. Example

View license
public override DbDataReader GetResultSet(DbCommand statement)
		{
			var rdr = statement.ExecuteReader();
			return rdr;
		}

8. Example

Project: effort
Source File: EntityTableDataLoader.cs
View license
protected override IDataReader CreateDataReader()
        {
            // Build a command tree, which queries all records
            DbCommandTree commandTree = 
                CommandTreeBuilder.CreateSelectAll(this.workspace, this.entitySet);
            
            // Get the provider services of the wrapped connection
            DbProviderServices providerServices = 
                DbProviderServices.GetProviderServices(this.connection.StoreConnection);
            
            // Get current manifest token
            string manifestToken = 
                providerServices.GetProviderManifestToken(this.connection.StoreConnection);
            
            // Get provider manifest
            DbProviderManifest providerManifest = 
                providerServices.GetProviderManifest(manifestToken);

            // Create a command definition from the command tree
            DbCommandDefinition commandDefinition = 
                providerServices.CreateCommandDefinition(providerManifest, commandTree);
            
            // Compile command 
            DbCommand command = commandDefinition.CreateCommand();

            // Setup command 
            command.Connection = this.connection.StoreConnection;
            
            // Execute
            DbDataReader reader = command.ExecuteReader();

            return reader;
        }

9. Example

Project: EDDiscovery
Source File: TravelLogUnit.cs
View license
public static TravelLogUnit Get(string name)
        {
            using (SQLiteConnectionUser cn = new SQLiteConnectionUser(mode: EDDbAccessMode.Reader))
            {
                using (DbCommand cmd = cn.CreateCommand("SELECT * FROM TravelLogUnit WHERE Name = @name ORDER BY Id DESC"))
                {
                    cmd.AddParameterWithValue("@name", name);
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            return new TravelLogUnit(reader);
                        }
                    }
                }
            }

            return null;
        }

10. Example

Project: EDDiscovery
Source File: TravelLogUnit.cs
View license
public static TravelLogUnit Get(long id)
        {
            using (SQLiteConnectionUser cn = new SQLiteConnectionUser(mode: EDDbAccessMode.Reader))
            {
                using (DbCommand cmd = cn.CreateCommand("SELECT * FROM TravelLogUnit WHERE Id = @id ORDER BY Id DESC"))
                {
                    cmd.AddParameterWithValue("@id", id);
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            return new TravelLogUnit(reader);
                        }
                    }
                }
            }

            return null;
        }

11. Example

Project: EDDiscovery
Source File: SystemClassEDSM.cs
View license
private static Dictionary<long, SystemClassBase> GetEdsmSystemsLite()
        {
            us/n ..... /n //View Source file for more details /n }

12. Example

Project: Goo-Micro-ORM
Source File: DBManager.cs
View license
public DbDataReader ExecuteReader()
        {
            OpenConnection();

            return command.ExecuteReader();
        }

13. Example

Project: Restful
Source File: SessionProvider.cs
View license
public virtual IDataReader ExecuteDataReader( CommandBuilder builder )
        {
            using( DbCommand command = this.CreateSqlCommand( builder ) )
            {
                return command.ExecuteReader();
            }
        }

14. Example

Project: Weed3
Source File: SQLer.cs
View license
private DbReader query(Command cmd, DbTran transaction) {
            if (false == buildCMD(cmd, (transaction == null ? null : transaction.connection), false)) {
                return null;
            }

            //3.??
            DbReader rst =  new DbReader(stmt.ExecuteReader());//stmt.executeQuery();

            //*.??
            WeedConfig.logExecuteAft(cmd);

            return rst;
        }

15. Example

Project: Weed3
Source File: SQLer.cs
View license
private DbReader query(Command cmd, DbTran transaction) {
            DbCommand dbcmd = null;
            if (transaction == null)
                dbcmd = buildCMD(cmd, null, false);
            else
                dbcmd = buildCMD(cmd, transaction.connection, false);
            
            //3.??
            return new DbReader(dbcmd.ExecuteReader());//stmt.executeQuery();
        }

16. Example

View license
private LabeledDbDataReader GetReader(DbConnection conn, string tsql)
        {
            string label = GetLabel(conn);
            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandText = tsql;
            DbDataReader sdr = cmd.ExecuteReader();
            return new LabeledDbDataReader(sdr, new ShardLocation(cmd.Connection.DataSource, cmd.Connection.Database), new MockSqlCommand() { Connection = conn });
        }

17. Example

Project: Cheezburger-BDSM
Source File: Importer.cs
View license
private IDataReader ExecuteReader(string commandText, params object[] args)
        {
            try
            {
                using (DbCommand command = CreateCommand(commandText, args))
                    return command.ExecuteReader();
            }
            catch (Exception ex)
            {
                throw new Exception("Error in command: " + commandText, ex);
            }
        }

18. Example

Project: MdxClient
Source File: MdxCommand.cs
View license
public override object ExecuteScalar()
        {
            object result = null;
            using (var ds = ExecuteReader())
            {
                if (ds.Read() && ds.FieldCount > 0)
                {
                    result = ds.GetValue(0);
                }             
            }
            return result;
        }

19. Example

Project: EDDiscovery
Source File: SQLiteConnectionED.cs
View license
protected void GetRegister(Dictionary<string, RegisterEntry> regs)
        {
            using (DbCommand cmd = CreateCommand("SELECT Id, ValueInt, ValueDouble, ValueBlob, ValueString FROM register"))
            {
                using (DbDataReader rdr = cmd.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        string id = (string)rdr["Id"];
                        object valint = rdr["ValueInt"];
                        object valdbl = rdr["ValueDouble"];
                        object valblob = rdr["ValueBlob"];
                        object valstr = rdr["ValueString"];
                        regs[id] = new RegisterEntry(
                            valstr as string,
                            valblob as byte[],
                            (valint as long?) ?? 0L,
                            (valdbl as double?) ?? Double.NaN
                        );
                    }
                }
            }
        }

20. Example

Project: EDDiscovery
Source File: SystemClassDB.cs
View license
public static List<long> GetEdsmIdsFromName(string name, SQLiteConnectionSystem cn = null , bool uselike = false)
        {
            List<long> ret = new List<long>();

            if (name!=null && name.Length > 0)
            {
                bool ownconn = false;
                try
                {
                    if (cn == null)
                    {
                        ownconn = true;
                        cn = new SQLiteConnectionSystem();
                    }

                    using (DbCommand cmd = cn.CreateCommand("SELECT Name,EdsmId FROM SystemNames WHERE " + (uselike? "Name like @first" : "[email protected]") ))
                    {
                        cmd.AddParameterWithValue("first", name + (uselike ? "%" : ""));

                        using (DbDataReader rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                ret.Add((long)rdr[1]);
                            }
                        }
                    }
                }
                finally
                {
                    if (ownconn)
                    {
                        cn.Dispose();
                    }
                }
            }

            return ret;
        }

21. Example

Project: EDDiscovery
Source File: SystemClassDB.cs
View license
public static long GetTotalSystemsFast()
        {
            long value = 0;

            try
            {
                using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem())
                {
                    using (DbCommand cmd = cn.CreateCommand("select MAX(Id) from EdsmSystems"))
                    {
                        using (DbDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.Read())
                                value = (long)reader["MAX(Id)"];
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("Exception : " + ex.Message);
                System.Diagnostics.Trace.WriteLine(ex.StackTrace);
            }

            return value;
        }

22. Example

Project: EDDiscovery
Source File: SystemClassDB.cs
View license
public static long GetTotalSystems()
        {
            long value = 0;

            try
            {
                using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem())
                {
                    using (DbCommand cmd = cn.CreateCommand("select Count(*) from EdsmSystems"))
                    {
                        using (DbDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.Read())
                                value = (long)reader["Count(*)"];
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("Exception : " + ex.Message);
                System.Diagnostics.Trace.WriteLine(ex.StackTrace);
            }

            return value;
        }

23. Example

Project: EDDiscovery
Source File: SystemClassDB.cs
View license
public static bool IsSystemsTableEmpty()
        {
            bool isempty = true;

            try
            {
                using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem())
                {
                    using (DbCommand cmd = cn.CreateCommand("select Id from EdsmSystems LIMIT 1"))
                    {
                        using (DbDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.Read())
                                isempty = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("Exception : " + ex.Message);
                System.Diagnostics.Trace.WriteLine(ex.StackTrace);
            }

            return isempty;
        }

24. Example

Project: EDDiscovery
Source File: SystemClassDB.cs
View license
public static ISystem GetSystemNearestTo(double x, double y, double z, SQLiteConnectionSystem conn)
        {
            using (DbCommand selectByPosCmd = conn.CreateCommand(
                "SELECT s.EdsmId FROM EdsmSystems s " +         // 16 is 0.125 of 1/128, so pick system near this one
                "WHERE s.X >= @X - 16 " +
                "AND s.X <= @X + 16 " +
                "AND s.Y >= @Y - 16 " +
                "AND s.Y <= @Y + 16 " +
                "AND s.Z >= @Z - 16 " +
                "AND s.Z <= @Z + 16 LIMIT 1"))
            {
                selectByPosCmd.AddParameterWithValue("@X", (long)(x * XYZScalar));
                selectByPosCmd.AddParameterWithValue("@Y", (long)(y * XYZScalar));
                selectByPosCmd.AddParameterWithValue("@Z", (long)(z * XYZScalar));

                using (DbDataReader reader = selectByPosCmd.ExecuteReader())        // MEASURED very fast, <1ms
                {
                    while (reader.Read())
                    {
                        long pos_edsmid = (long)reader["EdsmId"];
                        ISystem sys = GetSystem(pos_edsmid, conn, SystemIDType.EdsmId);
                        return sys;
                    }
                }
            }

            return null;
        }

25. Example

Project: EDDiscovery
Source File: SystemClassDB.cs
View license
public static List<string> ReturnOnlySystemsListForAutoComplete(string input, Object ctrl)
        {
            List<string> ret = new List<string>();
            if (input != null && input.Length > 0)
            {
                using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem())
                {
                    using (DbCommand cmd = cn.CreateCommand("SELECT Name,EdsmId FROM SystemNames WHERE Name>[email protected] AND Name<[email protected] LIMIT 1000"))
                    {
                        cmd.AddParameterWithValue("first", input);
                        cmd.AddParameterWithValue("second", input + "~");

                        using (DbDataReader rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                ret.Add((string)rdr[0]);
                            }
                        }
                    }
                }
            }
            return ret;
        }

26. Example

Project: EDDiscovery
Source File: SystemClassDB.cs
View license
private static bool privTryGetMergedSystem(string systemName, out ISystemBase result, SQLiteConnectionSystem cn = null)
        {
            result = null;
            bool createdCn = false;
            long edsmMergedId = long.MinValue;

            try
            {
                if (cn == null)
                {
                    createdCn = true;
                    cn = new SQLiteConnectionSystem();
                }
                using (DbCommand cmd = cn.CreateCommand("SELECT id_edsm_mergedto FROM SystemAliases WHERE name = @param1 LIMIT 1"))
                {
                    cmd.AddParameterWithValue("param1", systemName);
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                            edsmMergedId = (long)reader["id_edsm_mergedto"];
                    }
                }
                if (edsmMergedId != long.MinValue)
                    result = GetSystem(edsmMergedId, cn, SystemIDType.EdsmId);
            }
            finally
            {
                if (createdCn && cn != null)
                    cn.Dispose();
            }

            return (result != null);
        }

27. Example

Project: EDDiscovery
Source File: TravelLogUnit.cs
View license
public static List<string> GetAllNames()
        {
            List<string> names = new List<string>();
            using (SQLiteConnectionUser cn = new SQLiteConnectionUser(mode: EDDbAccessMode.Reader))
            {
                using (DbCommand cmd = cn.CreateCommand("SELECT DISTINCT Name FROM TravelLogUnit"))
                {
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            names.Add((string)reader["Name"]);
                        }
                    }
                }
            }
            return names;
        }

28. Example

Project: EDDiscovery
Source File: JournalEntry.cs
View license
static public JObject GetJson(long journalid, SQLiteConnectionUser cn, DbTransaction tn = null)
        {
            using (DbCommand cmd = cn.CreateCommand("select EventData from JournalEntries where [email protected]", tn))
            {
                cmd.AddParameterWithValue("@journalid", journalid);

                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string EDataString = (string)reader["EventData"];
                        return JObject.Parse(EDataString);
                    }
                }
            }

            return null;
        }

29. Example

Project: EDDiscovery
Source File: JournalEntry.cs
View license
static public JournalEntry Get(long journalid, SQLiteConnectionUser cn, DbTransaction tn = null)
        {
            using (DbCommand cmd = cn.CreateCommand("select * from JournalEntries where [email protected]", tn))
            {
                cmd.AddParameterWithValue("@journalid", journalid);

                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        return CreateJournalEntry(reader);
                    }
                }
            }

            return null;
        }

30. Example

Project: nanoprofiler
Source File: ProfiledDbCommand.cs
View license
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
        {
            var dbProfiler = _getDbProfiler();
            if (dbProfiler == null) return _dbCommand.ExecuteReader();

            DbDataReader reader = null;
            dbProfiler.ExecuteDbCommand(
                DbExecuteType.Reader
                , _command
                , () => reader = _dbCommand.ExecuteReader(behavior)
                , Tags);

            var profiledReader = reader as ProfiledDbDataReader;
            if (profiledReader != null)
            {
                return profiledReader;
            }

            return new ProfiledDbDataReader(reader, dbProfiler);
        }

31. Example

Project: RiotControl
Source File: DatabaseCommand.cs
View license
public DatabaseReader ExecuteReader()
		{
			Start();
			DbDataReader reader = Command.ExecuteReader();
			Stop();
			DatabaseReader wrappedReader = new DatabaseReader(reader);
			return wrappedReader;
		}

32. Example

View license
public static IEnumerable<T> Select<T>(this DbCommand command, Func<DbDataReader, T> selector)
        {
            using (var reader = command.ExecuteReader())
                return reader.Select(selector).ToList();
        }

33. Example

Project: simple-1c
Source File: AbstractSqlDatabase.cs
View license
public bool Exists(string sql, params object[] args)
        {
            return ExecuteWithResult(sql, args, c =>
            {
                using (var reader = c.ExecuteReader())
                    return reader.Read();
            });
        }

34. Example

View license
protected override DbDataReader ExecuteDbDataReader(System.Data.CommandBehavior behavior)
        {
            List<DbCommand> statements = splitStatements();
            if (statements.Count == 0)
                throw new NuoDbSqlException("No statement specified");
            for (int i = 0; i < statements.Count - 1; i++)
                statements[i].ExecuteNonQuery();
            if (ExpectedColumnTypes != null)
                return new TypedDbReader(statements[statements.Count - 1].ExecuteReader(), ExpectedColumnTypes);
            return statements[statements.Count-1].ExecuteReader();
        }

35. Example

Project: SummerBatch
Source File: DataReaderItemReader.cs
View license
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities")]
        private void InitializeDataReader()
        {
            var parsedQuery = new ParsedQuery(Query, DatabaseExtensionManager.GetPlaceholderGetter(ConnectionString.ProviderName));
            _command = _connection.CreateCommand();
            _command.CommandText = parsedQuery.SubstitutedQuery;
            SetParameters(parsedQuery);
            _dataReader = _command.ExecuteReader();
        }

36. Example

Project: EDDiscovery
Source File: SQLiteConnectionUser.cs
View license
public List<EDCommander> GetCommanders()
        {
            List<EDCommander> commanders = new List<EDCommander>();

            if (GetSettingInt("DBVer", 1) >= 102)
            {
                using (DbCommand cmd = CreateCommand("SELECT * FROM Commanders"))
                {
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            EDCommander edcmdr = new EDCommander(reader);

                            string name = Convert.ToString(reader["Name"]);
                            string edsmapikey = Convert.ToString(reader["EdsmApiKey"]);

                            commanders.Add(edcmdr);
                        }
                    }
                }
            }

            return commanders;
        }

37. Example

Project: EDDiscovery
Source File: SystemClassDB.cs
View license
public static List<Point3D> GetStarPositions()  // return star positions..
        {
            List<Point3D> list = new List<Point3D>();

            try
            {
                using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem())
                {
                    using (DbCommand cmd = cn.CreateCommand("select x,y,z from EdsmSystems"))
                    {
                        using (DbDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                if (System.DBNull.Value != reader["x"])
                                    list.Add(new Point3D(((double)(long)reader["x"]) / XYZScalar, ((double)(long)reader["y"]) / XYZScalar, ((double)(long)reader["z"]) / XYZScalar));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("Exception : " + ex.Message);
                System.Diagnostics.Trace.WriteLine(ex.StackTrace);
            }
            return list;
        }

38. Example

Project: EDDiscovery
Source File: SystemClassDB.cs
View license
public static DateTime GetLastSystemModifiedTime()
        {
            DateTime lasttime = new DateTime(2010, 1, 1, 0, 0, 0);

            try
            {
                using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem())
                {
                    using (DbCommand cmd = cn.CreateCommand("SELECT UpdateTimestamp FROM EdsmSystems ORDER BY UpdateTimestamp DESC LIMIT 1"))
                    {
                        using (DbDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.Read() && System.DBNull.Value != reader["UpdateTimestamp"])
                                lasttime = new DateTime(2015, 1, 1, 0, 0, 0, DateTimeKind.Utc) + TimeSpan.FromSeconds((long)reader["UpdateTimestamp"]);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("Exception : " + ex.Message);
                System.Diagnostics.Trace.WriteLine(ex.StackTrace);
            }

            return lasttime;
        }

39. Example

Project: EDDiscovery
Source File: SystemClassDB.cs
View license
public static DateTime GetLastSystemModifiedTimeFast()
        {
            DateTime lasttime = new DateTime(2010, 1, 1, 0, 0, 0);

            try
            {
                using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem())
                {
                    using (DbCommand cmd = cn.CreateCommand("SELECT UpdateTimestamp FROM EdsmSystems ORDER BY Id DESC LIMIT 1"))
                    {
                        using (DbDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.Read() && System.DBNull.Value != reader["UpdateTimestamp"])
                                lasttime = new DateTime(2015, 1, 1, 0, 0, 0, DateTimeKind.Utc) + TimeSpan.FromSeconds((long)reader["UpdateTimestamp"]);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("Exception : " + ex.Message);
                System.Diagnostics.Trace.WriteLine(ex.StackTrace);
            }

            return lasttime;
        }

40. Example

Project: EDDiscovery
Source File: JournalEntry.cs
View license
public static List<JournalEntry> GetAllByTLU(long tluid)
        {
            TravelLogUnit tlu = TravelLogUnit.Get(tluid);
            List<JournalEntry> vsc = new List<JournalEntry>();

            using (SQLiteConnectionUser cn = new SQLiteConnectionUser(utc: true))
            {
                using (DbCommand cmd = cn.CreateCommand("SELECT * FROM JournalEntries WHERE TravelLogId = @source ORDER BY EventTime ASC"))
                {
                    cmd.AddParameterWithValue("@source", tluid);
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            JournalEntry je = CreateJournalEntry(reader);
                            je.beta = tlu?.Beta ?? false;
                            vsc.Add(je);
                        }
                    }
                }
            }
            return vsc;
        }

41. Example

Project: EDDiscovery
Source File: JournalEntry.cs
View license
public static JournalEntry GetLast(int cmdrid, DateTime before, Func<JournalEntry, bool> filter)
        {
            using (SQLiteConnectionUser cn = new SQLiteConnectionUser(utc: true))
            {
                using (DbCommand cmd = cn.CreateCommand("SELECT * FROM JournalEntries WHERE CommanderId = @cmdrid AND EventTime < @time ORDER BY EventTime DESC"))
                {
                    cmd.AddParameterWithValue("@cmdrid", cmdrid);
                    cmd.AddParameterWithValue("@time", before);
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            JournalEntry ent = CreateJournalEntry(reader);
                            if (filter(ent))
                            {
                                return ent;
                            }
                        }
                    }
                }
            }

            return null;
        }

42. Example

Project: EDDiscovery
Source File: JournalEntry.cs
View license
public static JournalEntry GetLast(DateTime before, Func<JournalEntry, bool> filter)
        {
            using (SQLiteConnectionUser cn = new SQLiteConnectionUser(utc: true))
            {
                using (DbCommand cmd = cn.CreateCommand("SELECT * FROM JournalEntries WHERE EventTime < @time ORDER BY EventTime DESC"))
                {
                    cmd.AddParameterWithValue("@time", before);
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            JournalEntry ent = CreateJournalEntry(reader);
                            if (filter(ent))
                            {
                                return ent;
                            }
                        }
                    }
                }
            }

            return null;
        }

43. Example

Project: RawDataAccessBencher
Source File: Massive.cs
View license
public virtual IEnumerable<dynamic> Query(string sql, DbConnection connection, params object[] args)
		{
			using(var rdr = CreateCommand(sql, connection, args).ExecuteReader())
			{
				while(rdr.Read())
				{
					yield return rdr.RecordToExpando(); ;
				}
			}
		}

44. Example

Project: simple-1c
Source File: AbstractSqlDatabase.cs
View license
public IEnumerable<T> ExecuteEnumerable<T>(string commandText, object[] args, Func<DbDataReader, T> map)
        {
            return ExecuteWithResult(commandText, args, c =>
            {
                using (var reader = c.ExecuteReader())
                    return ReadAll(reader, map).ToArray();
            });
        }

45. Example

Project: sqlhelper2
Source File: CommandDatabase.cs
View license
public IEnumerable<T> ExecuteDataReader<T>(string sql, object parameters, Func<DbDataReader, T> action) {
            PrepareCommand(sql, parameters);

            using (var dr = Command.ExecuteReader()) {
                while (dr.Read())
                    yield return action.Invoke(dr);
            }
        }

46. Example

Project: sqlhelper2
Source File: CommandDatabase.cs
View license
public void ExecuteDataReader(string sql, object parameters, Action<DbDataReader> action) {
            PrepareCommand(sql, parameters);

            using (var dr = Command.ExecuteReader()) {
                while (dr.Read())
                    action.Invoke(dr);
            }
        }

47. Example

Project: sqlhelper2
Source File: DatabaseInTx.cs
View license
public IEnumerable<T> ExecuteReader<T>(string sql, object parameters, Func<DbDataReader, T> action) {
            PrepareCommand(sql, parameters);
            using (var dr = _Command.ExecuteReader()) {
                while (dr.Read())
                    yield return action.Invoke(dr);
            }
        }

48. Example

View license
protected internal sealed override IEnumerable Execute(string sql, IReadOnlyList<Parameter> parameters, Type resultType)
        {
            using (var connection = this.GetConnection())
            using (var command = this.CreateCommand(connection.Connection, sql, parameters))
            {
                if (this.options.CommandTimeout.HasValue)
                {
                    command.CommandTimeout = this.options.CommandTimeout.Value;
                }

                using (var reader = command.ExecuteReader())
                {
                    foreach (var result in this.MaterializeReader(reader, resultType))
                    {
                        yield return result;
                    }
                }
            }
        }

49. Example

Project: ReliableDbProvider
Source File: Massive.cs
View license
public virtual IEnumerable<dynamic> Query(string sql, DbConnection connection, params object[] args)
        {
            using (var rdr = CreateCommand(sql, connection, args).ExecuteReader())
            {
                while (rdr.Read())
                {
                    yield return rdr.RecordToExpando(); ;
                }
            }
        }

50. Example

Project: NServiceKit.OrmLite
Source File: Massive.cs
View license
public virtual IEnumerable<dynamic> Query(string sql, DbConnection connection, params object[] args)
        {
            using (var rdr = CreateCommand(sql, connection, args).ExecuteReader())
            {
                while (rdr.Read())
                {
                    yield return rdr.RecordToExpando(); ;
                }
            }

        }