/// <summary>Get Service Package Promotion</summary> /// <cardinality>Many</cardinality> public List <ServicePackagePromotionWithFilterData> ServicePackagePromotionWithFilter( System.Guid clientId ) { var ret = new List <ServicePackagePromotionWithFilterData>(); string sql = @"select sp.service_package_name as service_package_name ,spp.client_id ,c.first_name + ' ' + c.last_name as client_name ,spp.promotion_price_amount ,spp.financial_currency_id ,fc.financial_currency_type_name as financial_currency_type_name ,spp.user_id ,du.default_user_name ,spp.date_time ,spp.service_package_promotion_id ,spp.service_package_id from service_package_promotion as spp inner join service_package as sp on sp.service_package_id = spp.service_package_id inner join client as c on c.client_id = spp.client_id inner join financial_currency as fc on fc.financial_currency_id = spp.financial_currency_id inner join default_user as du on du.default_user_id = spp.user_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("@client_id", SqlDbType.UniqueIdentifier).Value = clientId; Logging log = Logging.PerformanceTimeStart("ServicePackagePromotionWithFilter"); IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult); log.PerformanceTimeStop(sql, command); var ordinals = new ServicePackagePromotionWithFilterDataOrdinals(reader); while (reader.Read()) { var data = new ServicePackagePromotionWithFilterData(); data.Populate(reader, ordinals); ret.Add(data); } reader.Close(); } return(ret); } }
// 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, ServicePackagePromotionWithFilterDataOrdinals ordinals) { if (!reader.IsDBNull(ordinals.ServicePackageName)) { ServicePackageName = reader.GetString(ordinals.ServicePackageName); } if (!reader.IsDBNull(ordinals.ClientId)) { ClientId = reader.GetGuid(ordinals.ClientId); } if (!reader.IsDBNull(ordinals.ClientName)) { ClientName = reader.GetString(ordinals.ClientName); } if (!reader.IsDBNull(ordinals.PromotionPriceAmount)) { PromotionPriceAmount = reader.GetDecimal(ordinals.PromotionPriceAmount); } if (!reader.IsDBNull(ordinals.FinancialCurrencyId)) { FinancialCurrencyId = reader.GetGuid(ordinals.FinancialCurrencyId); } if (!reader.IsDBNull(ordinals.FinancialCurrencyTypeName)) { FinancialCurrencyTypeName = reader.GetString(ordinals.FinancialCurrencyTypeName); } if (!reader.IsDBNull(ordinals.UserId)) { UserId = reader.GetGuid(ordinals.UserId); } if (!reader.IsDBNull(ordinals.DefaultUserName)) { DefaultUserName = reader.GetString(ordinals.DefaultUserName); } if (!reader.IsDBNull(ordinals.DateTime)) { DateTime = reader.GetDateTime(ordinals.DateTime); } if (!reader.IsDBNull(ordinals.ServicePackagePromotionId)) { ServicePackagePromotionId = reader.GetGuid(ordinals.ServicePackagePromotionId); } if (!reader.IsDBNull(ordinals.ServicePackageId)) { ServicePackageId = reader.GetGuid(ordinals.ServicePackageId); } }