Exemplo n.º 1
0
 // use ordinals to speed up access to DataReader
 // links:
 //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
 //  docLink: http://sql2x.org/documentationLink/327451c3-64a8-4de8-b359-76742d634497
 // parameters:
 //  reader: IDataReader from SQLClient
 public void Populate(IDataReader reader, DefaultPerformanceTimesDataOrdinals ordinals)
 {
     if (!reader.IsDBNull(ordinals.DateTime))
     {
         DateTime = reader.GetDateTime(ordinals.DateTime);
     }
     if (!reader.IsDBNull(ordinals.Milliseconds))
     {
         Milliseconds = reader.GetInt32(ordinals.Milliseconds);
     }
 }
Exemplo n.º 2
0
        /// <summary>Get list of available performance time commands</summary>
        /// <cardinality>Many</cardinality>
        public List <DefaultPerformanceTimesData> DefaultPerformanceTimes(
            string commandName
            )
        {
            var ret = new List <DefaultPerformanceTimesData>();

            string sql = @" 
                 select top 50
	                dpt.date_time,
	                dpt.milliseconds
                 from default_performance_time as dpt
                 where dpt.command_name = @command_name
                 order by date_time
                ";

            Logging log = Logging.PerformanceTimeStart("Default", "DataAccessLayer", "DefaultSearch", "DefaultPerformanceTimes");

            try {
                using (var conn = new SqlConnection(Conn.ConnectionString)) {
                    conn.Open();
                    conn.BeginTransaction(IsolationLevel.ReadUncommitted).Commit();

                    using (var command = new SqlCommand(sql, conn)) {
                        command.Parameters.Add("@command_name", SqlDbType.VarChar).Value = commandName;
                        log.PerformanceTimePrepare(command);
                        IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
                        log.PerformanceTimeCheck();

                        var ordinals = new DefaultPerformanceTimesDataOrdinals(reader);
                        while (reader.Read())
                        {
                            var data = new DefaultPerformanceTimesData();
                            data.Populate(reader, ordinals);
                            ret.Add(data);
                        }

                        reader.Close();
                    }
                }
            } catch (Exception ex) {
                log.Error(ex);
            }
            return(ret);
        }