Beispiel #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, ServiceFerryListDataOrdinals ordinals)
 {
     if (!reader.IsDBNull(ordinals.FerryName))
     {
         FerryName = reader.GetString(ordinals.FerryName);
     }
     if (!reader.IsDBNull(ordinals.Amount))
     {
         Amount = reader.GetDecimal(ordinals.Amount);
     }
     if (!reader.IsDBNull(ordinals.FinancialCurrencyTypeName))
     {
         FinancialCurrencyTypeName = reader.GetString(ordinals.FinancialCurrencyTypeName);
     }
     if (!reader.IsDBNull(ordinals.FerryId))
     {
         FerryId = reader.GetGuid(ordinals.FerryId);
     }
     if (!reader.IsDBNull(ordinals.ProductId))
     {
         ProductId = reader.GetGuid(ordinals.ProductId);
     }
     if (!reader.IsDBNull(ordinals.ServiceFerryId))
     {
         ServiceFerryId = reader.GetGuid(ordinals.ServiceFerryId);
     }
 }
Beispiel #2
0
        /// <summary>Service ferry rental List</summary>
        /// <cardinality>Many</cardinality>
        public List <ServiceFerryListData> ServiceFerryList(
            )
        {
            var ret = new List <ServiceFerryListData>();

            string sql = @" 
                select 
                     f.ferry_name
	                ,sf.amount								
	                ,fc.financial_currency_type_name			
                    ,f.ferry_id
                    ,f.product_id
                    ,sf.service_ferry_id
                from service_ferry						as sf
                inner join ferry						as f	on	f.ferry_id = sf.ferry_id
                inner join financial_currency			as fc	on	fc.financial_currency_id = sf.financial_currency_id
                order by f.ferry_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.ServiceFerryList");
                    IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
                    log.PerformanceTimeStop(sql, command);

                    var ordinals = new ServiceFerryListDataOrdinals(reader);

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

                    reader.Close();
                }

                return(ret);
            }
        }