//insert
        public static void Insert(DbLink dbLink, fcs ffd)
        {
            string query =
                @"insert into fcs(cf_id, fi_id, ds_id, ct_id)
                    values(nextval('mir_sequence'), @fi_id, @ds_id, @ct_id);";

            dbLink.GetConnection().Execute(query, ffd);
        }
        private void Save(Dictionary <PortfolioPosition, CashFlow> dictionary)
        {
            foreach (var x in dictionary)
            {
                var transaction = _dbLink.GetConnection().BeginTransaction(IsolationLevel.ReadCommitted);
                try
                {
                    var    finIdent     = x.Key.Ident;
                    var    finType      = x.Key.FinType;
                    string finTypeIdent = _mapping.GetAI(finType);

                    #region финансовый инструмент
                    fin_instrument finInstrument = new fin_instrument()
                    {
                        ident = finIdent,
                        title = finIdent,
                        ft_id = int.Parse(finTypeIdent)
                    };

                    if (FinInstrument.FindId(_dbLink, finInstrument.ident) == null)
                    {
                        FinInstrument.Insert(_dbLink, finInstrument);
                    }

                    finInstrument = FinInstrument.FindId(_dbLink, finInstrument.ident);
                    #endregion

                    #region Data_source
                    data_source dataSource = new data_source()
                    {
                        ident = _providerParams[SCALAR].ToString(),
                    };

                    dataSource = DataSource.FindId(_dbLink, dataSource.ident);
                    #endregion

                    #region fcs
                    fcs ffd = new fcs()
                    {
                        ds_id = dataSource.ds_id,
                        fi_id = finInstrument.fi_id,
                        ct_id = int.Parse(_mapping.GetAI(x.Value.Attribute))
                    };

                    if (FCS.Find(_dbLink, ffd.fi_id, ffd.ds_id, ffd.ct_id) == null)
                    {
                        FCS.Insert(_dbLink, ffd);
                    }
                    ffd = FCS.Find(_dbLink, ffd.fi_id, ffd.ds_id, ffd.ct_id);
                    #endregion

                    #region Денежный поток
                    foreach (var z in x.Value.Values)
                    {
                        cashflow cf = new cashflow()
                        {
                            cf_id     = ffd.cf_id,
                            dat       = z.Key,
                            val       = z.Value,
                            valid_dat = (DateTime)_providerParams[REPORTDATE]
                        };

                        if (Cashflow.FindId(_dbLink, cf.cf_id, cf.dat, cf.valid_dat) == null)
                        {
                            //первое значение, следовательно 01.01.1900 год
                            cf.valid_dat = new DateTime(1900, 01, 01);
                            Cashflow.Insert(_dbLink, cf);
                        }
                        else
                        {
                            Cashflow.Insert(_dbLink, cf);
                        }
                    }
                    #endregion


                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                }
            }
        }