Beispiel #1
0
        public IEnumerable <LogRecord> GetRecords(int numberOfRecords, long?recordId, bool showHeader = false)
        {
            if (dbConnection == null)
            {
                dbConnection = _connectionWrapper.CreateConnection();
            }
            if (dbConnection.State == ConnectionState.Closed)
            {
                dbConnection.Open();
            }
            var prm = new DynamicParameters();

            prm.Add("@recordlimit", numberOfRecords);
            prm.Add("@recordid", recordId);

            var reader = dbConnection.ExecuteReader(defaultStoredProcedure, prm, commandType: CommandType.StoredProcedure);

            if (showHeader)
            {
                yield return(GetSingleEntry(reader, true));
            }

            while (reader.Read())
            {
                yield return(GetSingleEntry(reader));
            }
        }
Beispiel #2
0
 public DbConnection CreateConnection()
 {
     // create a connection for operations that require holding an open connection to the db
     return(_connectionWrapper.CreateConnection());
 }