// 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, ServiceCarRentalListDataOrdinals ordinals)
 {
     if (!reader.IsDBNull(ordinals.CarName))
     {
         CarName = reader.GetString(ordinals.CarName);
     }
     if (!reader.IsDBNull(ordinals.DayPriceAmount))
     {
         DayPriceAmount = reader.GetDecimal(ordinals.DayPriceAmount);
     }
     if (!reader.IsDBNull(ordinals.FinancialCurrencyTypeName))
     {
         FinancialCurrencyTypeName = reader.GetString(ordinals.FinancialCurrencyTypeName);
     }
     if (!reader.IsDBNull(ordinals.ServiceCarRentalId))
     {
         ServiceCarRentalId = reader.GetGuid(ordinals.ServiceCarRentalId);
     }
 }
Exemple #2
0
        /// <summary>Service car rental List</summary>
        /// <cardinality>Many</cardinality>
        public List <ServiceCarRentalListData> ServiceCarRentalList(
            )
        {
            var ret = new List <ServiceCarRentalListData>();

            string sql = @" 
                select 
					 scr.car_name
	                ,scr.day_price_amount								
	                ,fc.financial_currency_type_name			
                    ,scr.service_car_rental_id
                from service_car_rental						as scr
                inner join financial_currency				as fc	on	fc.financial_currency_id = scr.financial_currency_id
                order by scr.car_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.ServiceCarRentalList");
                    IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
                    log.PerformanceTimeStop(sql, command);

                    var ordinals = new ServiceCarRentalListDataOrdinals(reader);

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

                    reader.Close();
                }

                return(ret);
            }
        }