Ejemplo 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, ServiceHotelListDataOrdinals ordinals)
 {
     if (!reader.IsDBNull(ordinals.HotelName))
     {
         HotelName = reader.GetString(ordinals.HotelName);
     }
     if (!reader.IsDBNull(ordinals.DayPriceAmount))
     {
         DayPriceAmount = reader.GetDecimal(ordinals.DayPriceAmount);
     }
     if (!reader.IsDBNull(ordinals.FinancialCurrencyTypeName))
     {
         FinancialCurrencyTypeName = reader.GetString(ordinals.FinancialCurrencyTypeName);
     }
     if (!reader.IsDBNull(ordinals.ServiceHotelId))
     {
         ServiceHotelId = reader.GetGuid(ordinals.ServiceHotelId);
     }
 }
Ejemplo n.º 2
0
        /// <summary>Service hotel List</summary>
        /// <cardinality>Many</cardinality>
        public List <ServiceHotelListData> ServiceHotelList(
            )
        {
            var ret = new List <ServiceHotelListData>();

            string sql = @" 
                select 
					 sh.hotel_name
	                ,sh.day_price_amount								
	                ,fc.financial_currency_type_name			
                    ,sh.service_hotel_id
                from service_hotel							as sh	
                inner join financial_currency				as fc	on	fc.financial_currency_id = sh.financial_currency_id
                order by sh.hotel_name
                ";

            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.FinancialSearch.ServiceHotelList");
                    IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
                    log.PerformanceTimeStop(sql, command);

                    var ordinals = new ServiceHotelListDataOrdinals(reader);

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

                    reader.Close();
                }

                return(ret);
            }
        }