public ScalarDate GetScalarDate(PortfolioPosition position, ScalarAttribute attribute) { if (!_mapping.FindAI(attribute)) { return(null); } KeyValuePair <PortfolioPosition, Enum> key = new KeyValuePair <PortfolioPosition, Enum>(position, attribute); if (_cache.ContainsKey(key)) { return((ScalarDate)_cache[key]); } ScalarDate scalarDate = null; string fif_id = _mapping.GetAI(attribute); string query = string.Format( @"SELECT fi.ident as ident, fd.dat_from as dat_from, fd.val as 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_date 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 <fisddate>(query); if (result != null && result.Count() != 0) { Dictionary <DateTime, DateTime> dict = new Dictionary <DateTime, DateTime>(); foreach (var x in result) { dict.Add(x.dat_from, x.val); } scalarDate = new ScalarDate(dict); } _cache.Add(key, scalarDate); return(scalarDate); }