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, DefaultPerformanceTimeCommandsDataOrdinals ordinals)
 {
     if (!reader.IsDBNull(ordinals.CommandName))
     {
         CommandName = reader.GetString(ordinals.CommandName);
     }
     if (!reader.IsDBNull(ordinals.CommandDisplayName))
     {
         CommandDisplayName = reader.GetString(ordinals.CommandDisplayName);
     }
 }
Exemplo n.º 2
0
        /// <summary>Get list of available performance time commands</summary>
        /// <cardinality>Many</cardinality>
        public List <DefaultPerformanceTimeCommandsData> DefaultPerformanceTimeCommands(
            )
        {
            var ret = new List <DefaultPerformanceTimeCommandsData>();

            string sql = @" 
                 select  
					 dpt.command_name 
					,iif(
						substring(	dpt.command_name, 
							len(dpt.command_name) 
							- charindex(
								'.', 
								reverse(dpt.command_name)) + 2, 200) = '', 
						dpt.command_name, 
						substring(	dpt.command_name, 
							len(dpt.command_name) 
							- charindex(
								'.', 
								reverse(dpt.command_name)) + 2, 200)
						)	as command_display_name
						
                from default_performance_time as dpt
                order by dpt.command_name 
                ";

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

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

                    using (var command = new SqlCommand(sql, conn)) {
                        log.PerformanceTimePrepare(command);
                        IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
                        log.PerformanceTimeCheck();

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

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