Esempio n. 1
0
        public IEnumerable <Event> GetEnumerable(long minEventId = 1, long maxEventId = long.MaxValue)
        {
            using (var conn = Database.Open())
            {
                using (var cmd = new SqlCommand("es.GetEnumerable", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@min", minEventId);
                    cmd.Parameters.AddWithValue("@max", maxEventId);

                    using (var reader = new SqlEventDataReader(cmd.ExecuteReader(CommandBehavior.SequentialAccess)))
                    {
                        while (reader.Read())
                        {
                            yield return(reader.Event);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public IEnumerable <Event> GetEnumerableStream(Guid streamId, int minSequenceNumber = 1, int maxSequenceNumber = int.MaxValue)
        {
            using (var conn = Database.Open())
            {
                using (var cmd = new SqlCommand("es.GetEnumerableStream", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@streamId", streamId);
                    cmd.Parameters.AddWithValue("@min", minSequenceNumber);
                    cmd.Parameters.AddWithValue("@max", maxSequenceNumber);

                    using (var reader = new SqlEventDataReader(cmd.ExecuteReader(CommandBehavior.SequentialAccess)))
                    {
                        while (reader.Read())
                        {
                            yield return(reader.Event);
                        }
                    }
                }
            }
        }