// 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, AircraftDetailsDataOrdinals ordinals)
 {
     if (!reader.IsDBNull(ordinals.AircraftName))
     {
         AircraftName = reader.GetString(ordinals.AircraftName);
     }
     if (!reader.IsDBNull(ordinals.AircraftFamilyImage))
     {
         AircraftFamilyImage = (System.Byte[])reader[ordinals.AircraftFamilyImage];
     }
     if (!reader.IsDBNull(ordinals.AircraftConfigurationName))
     {
         AircraftConfigurationName = reader.GetString(ordinals.AircraftConfigurationName);
     }
     if (!reader.IsDBNull(ordinals.AircraftBodyName))
     {
         AircraftBodyName = reader.GetString(ordinals.AircraftBodyName);
     }
     if (!reader.IsDBNull(ordinals.AircraftTypeName))
     {
         AircraftTypeName = reader.GetString(ordinals.AircraftTypeName);
     }
     if (!reader.IsDBNull(ordinals.ProductInfoValue))
     {
         ProductInfoValue = reader.GetString(ordinals.ProductInfoValue);
     }
     if (!reader.IsDBNull(ordinals.AircraftId))
     {
         AircraftId = reader.GetGuid(ordinals.AircraftId);
     }
 }
Exemple #2
0
        /// <summary>Get Aircraft details for PIM stuff</summary>
        /// <cardinality>Many</cardinality>
        public List <AircraftDetailsData> AircraftDetails()
        {
            var    ret = new List <AircraftDetailsData>();
            string sql = @"
SELECT 
     a.aircraft_name
	,atr.aircraft_family_image
    ,acr.aircraft_configuration_name
    ,abr.aircraft_body_name
    ,atr.aircraft_type_name
	,'' as product_info_value
    ,a.aircraft_id
FROM aircraft AS a
LEFT JOIN aircraft_configuration_ref AS acr
    ON acr.aircraft_configuration_rcd = a.aircraft_configuration_rcd
INNER JOIN aircraft_body_ref AS abr
    ON abr.aircraft_body_rcd = a.aircraft_body_rcd
INNER JOIN aircraft_type_ref AS atr
    ON atr.aircraft_type_rcd = a.aircraft_type_rcd
--realwhere
WHERE 1 = 1
";

            using (var conn = new SqlConnection(Conn.ConnectionString)) {
                conn.Open();

                using (var command = new SqlCommand(sql, conn)) {
                    command.CommandText = sql;

                    Logging     log    = Logging.PerformanceTimeStart("AircraftDetails");
                    IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
                    log.PerformanceTimeStop(sql, command);

                    var ordinals = new AircraftDetailsDataOrdinals(reader);

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

                    reader.Close();
                }

                return(ret);
            }
        }