Exemple #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, FlightScheduleDataOrdinals ordinals)
 {
     if (!reader.IsDBNull(ordinals.FlightScheduleId))
     {
         FlightScheduleId = reader.GetGuid(ordinals.FlightScheduleId);
     }
     if (!reader.IsDBNull(ordinals.AirlineIdentifierCode))
     {
         AirlineIdentifierCode = reader.GetString(ordinals.AirlineIdentifierCode);
     }
     if (!reader.IsDBNull(ordinals.AirlineName))
     {
         AirlineName = reader.GetString(ordinals.AirlineName);
     }
     if (!reader.IsDBNull(ordinals.FlightNumber))
     {
         FlightNumber = reader.GetString(ordinals.FlightNumber);
     }
     if (!reader.IsDBNull(ordinals.AircraftTypeName))
     {
         AircraftTypeName = reader.GetString(ordinals.AircraftTypeName);
     }
     if (!reader.IsDBNull(ordinals.DepartureAirportIdentifierCode))
     {
         DepartureAirportIdentifierCode = reader.GetString(ordinals.DepartureAirportIdentifierCode);
     }
     if (!reader.IsDBNull(ordinals.DepartureAirportName))
     {
         DepartureAirportName = reader.GetString(ordinals.DepartureAirportName);
     }
     if (!reader.IsDBNull(ordinals.ArrivalAirportIdentifierCode))
     {
         ArrivalAirportIdentifierCode = reader.GetString(ordinals.ArrivalAirportIdentifierCode);
     }
     if (!reader.IsDBNull(ordinals.ArrivalAirportName))
     {
         ArrivalAirportName = reader.GetString(ordinals.ArrivalAirportName);
     }
     if (!reader.IsDBNull(ordinals.FromDateTime))
     {
         FromDateTime = reader.GetDateTime(ordinals.FromDateTime);
     }
     if (!reader.IsDBNull(ordinals.UntilDateTime))
     {
         UntilDateTime = reader.GetDateTime(ordinals.UntilDateTime);
     }
     if (!reader.IsDBNull(ordinals.SegmentCount))
     {
         SegmentCount = reader.GetInt32(ordinals.SegmentCount);
     }
 }
Exemple #2
0
        /// <summary>Get flight schedule</summary>
        /// <cardinality>Many</cardinality>
        public List <FlightScheduleData> FlightSchedule()
        {
            var ret = new List <FlightScheduleData>();

            string sql = @" 
                    select 
                         fs.flight_schedule_id
	                    ,ai.airline_identifier_code
	                    ,a.airline_name
						,fsi.flight_identifier_code		as flight_number
	                    ,atr.aircraft_type_name
	                    ,dai.airport_identifier_code	as departure_airport_identifier_code
	                    ,da.airport_name				as departure_airport_name
	                    ,aai.airport_identifier_code	as arrival_airport_identifier_code
	                    ,aa.airport_name				as arrival_airport_name
	                    ,fs.from_date_time
	                    ,fs.until_date_time
						,(	select count(1) 
							from flight_schedule_segment as fss
							where fss.flight_schedule_id = fs.flight_schedule_id
						 )								as segment_count
                    from flight_schedule			        as fs
                    inner join airline				        as a	on a.airline_id = fs.airline_id
                    inner join aircraft_type_ref	        as atr	on atr.aircraft_type_rcd = fs.aircraft_type_rcd
                    inner join airport				        as da	on da.airport_id = fs.departure_airport_id
                    inner join airport				        as aa	on aa.airport_id = fs.arrival_airport_id
                    inner join airport_identifier	        as dai	on dai.airport_id = fs.departure_airport_id
										                            and dai.airport_identifier_type_rcd = dbo.ref('airport_identifier_type_ref.AC3')
                    inner join airport_identifier	        as aai	on aai.airport_id = fs.arrival_airport_id
										                            and aai.airport_identifier_type_rcd = dbo.ref('airport_identifier_type_ref.AC3')
                    inner join airline_identifier	        as ai	on ai.airline_id = fs.airline_id
										                            and ai.airline_identifier_type_rcd = dbo.ref('airline_identifier_type_ref.AC2')
	                 left join flight_schedule_identifier	as fsi	on fsi.flight_schedule_id = fs.flight_schedule_id
															        and fsi.flight_identifier_type_rcd = dbo.ref('flight_identifier_type_ref.FN3')
                    --realwhere
                    where fs.became_flight_schedule_id is null
                    order by fs.from_date_time
                ";

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

                using (var command = new SqlCommand(sql, conn)) {
                    Logging     log    = Logging.PerformanceTimeStart("SolutionNorSolutionPort.DataAccessLayer.ScheduleSearch.FlightSchedule");
                    IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
                    log.PerformanceTimeStop(sql, command);

                    var ordinals = new FlightScheduleDataOrdinals(reader);

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

                    reader.Close();
                }

                return(ret);
            }
        }