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, PassengersOnBookingDataOrdinals ordinals)
 {
     if (!reader.IsDBNull(ordinals.PassengerId))
     {
         PassengerId = reader.GetGuid(ordinals.PassengerId);
     }
     if (!reader.IsDBNull(ordinals.PassengerName))
     {
         PassengerName = reader.GetString(ordinals.PassengerName);
     }
     if (!reader.IsDBNull(ordinals.PassengerTypeName))
     {
         PassengerTypeName = reader.GetString(ordinals.PassengerTypeName);
     }
 }
Exemple #2
0
        /// <summary>Get all passengers on a booking</summary>
        /// <cardinality>Many</cardinality>
        public List <PassengersOnBookingData> PassengersOnBooking(Guid bookingId)
        {
            var ret = new List <PassengersOnBookingData>();

            string sql = @" 
                    select
                         pa.passenger_id
	                    ,pa.passenger_name
	                    ,ptr.passenger_type_name
                    from passenger as pa 
                    inner join passenger_type_ref as ptr on ptr.passenger_type_rcd = pa.passenger_type_rcd
                    inner join booking_passenger as bp on bp.passenger_id = pa.passenger_id
                    where bp.booking_id = @booking_id
                ";

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

                using (var command = new SqlCommand(sql, conn)) {
                    command.Parameters.Add("@booking_id", SqlDbType.UniqueIdentifier).Value = bookingId;

                    Logging     log    = Logging.PerformanceTimeStart("SolutionNorSolutionPort.DataAccessLayer.PassengerSearch.PassengersOnBooking");
                    IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
                    log.PerformanceTimeStop(sql, command);

                    var ordinals = new PassengersOnBookingDataOrdinals(reader);

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

                    reader.Close();
                }

                return(ret);
            }
        }