Example #1
0
        /// <summary>
        /// Выбираем все стопы по объектам
        /// </summary>
        /// <param name="dc">Контекст базы данных</param>
        /// <returns></returns>
        public static Dictionary <int, List <StopSale> > GetAllStopSalesByObjects(this MtSearchDbDataContext dc)
        {
            Dictionary <int, List <StopSale> > stopSales;
            var hash = String.Format("{0}", MethodBase.GetCurrentMethod().Name);

            if ((stopSales = CacheHelper.GetCacheItem <Dictionary <int, List <StopSale> > >(hash)) != null)
            {
                return(stopSales);
            }

            stopSales = (from ss in dc.GetAllStopSales()
                         where ss.SS_QOID.HasValue
                         group ss by ss.SS_QOID.Value
                         into g
                         select new { g.Key, Items = g.ToList() })
                        .ToDictionary(g => g.Key, g => g.Items);

            CacheHelper.AddCacheData(hash, stopSales, new List <string>()
            {
                TableName
            }, Globals.Settings.Cache.LongCacheTimeout);
            return(stopSales);
        }