コード例 #1
0
        public static IList <NamedOffer> QueryOffers(ISession session, uint userId)
        {
            var query = new OfferQuery();

            query.SelectSynonyms();

            using (StorageProcedures.GetActivePrices((MySqlConnection)session.Connection, userId)) {
                var sql = query.ToSql()
                          .Replace(" as {Offer.Id.CoreId}", " as CoreId")
                          .Replace(" as {Offer.Id.RegionCode}", " as RegionId")
                          .Replace("{Offer.", "")
                          .Replace("}", "");
                var offers = session.CreateSQLQuery(sql)
                             .SetResultTransformer(new AliasToPropertyTransformer(typeof(NamedOffer)))
                             .List <NamedOffer>();
                var activePrices = session.Query <ActivePrice>().Where(p => p.Id.Price.PriceCode > 0).ToList();
                offers.Each(
                    offer =>
                    offer.PriceList =
                        activePrices.First(
                            price => price.Id.Price.PriceCode == offer.PriceCode && price.Id.RegionCode == offer.Id.RegionCode));
                return(offers);
            }
        }