public ScalarEnum GetScalarEnum(PortfolioPosition position,
                                        ScalarAttribute attribute)
        {
            KeyValuePair <PortfolioPosition, Enum> key =
                new KeyValuePair <PortfolioPosition, Enum>(position, attribute);

            if (!_cache.ContainsKey(key))
            {
                ScalarStr scalarStr = null;
                string    fif_id    = _mapping.GetAI(attribute);
                string    query     = string.Format(
                    @"SELECT fi.ident, fd.dat_from,  fd.val, *
                        from fin_instrument fi join
	                        ffd t on t.fi_id = fi.fi_id join
	                        data_source ds on t.ds_id = ds.ds_id join
	                        fisd_item fd on fd.fisd_id = t.fisd_id 
	                        where fi.ident = '{0}'
		                        and t.fif_id = {1}
		                        and ds.ident = '{2}'"        ,
                    position.Ident,
                    fif_id,
                    _providerParams[SCALAR]);
                var result = _dbLink.GetConnection().Query <fisdstring>(query);
                if (result != null && result.Count() != 0)
                {
                    Dictionary <DateTime, string> values = new Dictionary <DateTime, string>();
                    foreach (var x in result)
                    {
                        values.Add(x.dat_from, x.val);
                    }
                    scalarStr = new ScalarStr(values);
                }

                _cache.Add(key, scalarStr);
            }

            ScalarStr str = (ScalarStr)_cache[key];

            if (str == null)
            {
                return(null);
            }

            //прочитаем все значения
            if (!_mapping.FindET(attribute))
            {
                return(null);
            }

            Type type     = _mapping.GetET(attribute);
            var  bushuevs =
                Enum.GetValues(type).OfType <Enum>().OrderBy(z => z).ToList();

            if (bushuevs.Count == 0)
            {
                return(null);
            }

            Dictionary <DateTime, Enum> enumerations = new Dictionary <DateTime, Enum>();

            foreach (var x in str.Dictionary)
            {
                KeyValuePair <Type, string> keyEnum =
                    new KeyValuePair <Type, string>(type, x.Value);

                if (_mapping.TKE.ContainsKey(keyEnum))
                {
                    Enum enumeration = _mapping.TKE[keyEnum];
                    enumerations.Add(x.Key, enumeration);
                }
                else
                {
                    Enum enumeration = bushuevs.First();
                    enumerations.Add(x.Key, enumeration);
                }
            }
            ScalarEnum scalarEnum = new ScalarEnum(enumerations);

            //конвертируем их в соответствии с типом, если получается

            return(scalarEnum);
        }