Example #1
0
 public List <Moeda> FindAll()
 {
     using (var ctx = new CambioContext())
     {
         ctx.LazyLoading(false);
         var moedas = ctx.MoedaDao.FindAll();
         return(moedas);
     }
 }
Example #2
0
        private async void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            using (var ctx = new CambioContext())
            {
                ctx.LazyLoading(false);
                var moedas = await ctx.MoedaDao.FindAllAsync();

                cbMoedas.AddList <Moeda>(moedas);
                //cbMoedas.BeginInvoke(new Action(()=>{
                //    cbMoedas.AddList<Moeda>(moedas);

                //}));
            }
        }
Example #3
0
        public Moeda GetMoedaByCodigo(long codigo)
        {
            using (var ctx = new CambioContext())
            {
                ctx.LazyLoading(false);
                try
                {
                    //recupera a moeda pelo codigo de compra/venda
                    var moeda = ctx.MoedaDao.First(m =>
                                                   m.CodigoWSCompra == codigo ||
                                                   m.CodigoWSVenda == codigo);

                    return(moeda);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #4
0
        /// <summary>
        /// Cria um contexto
        /// </summary>
        /// <returns></returns>O Contexto
        private BalcaoContext createCtx()
        {
            try
            {
                //retorna o pai
                this._ctx = new BalcaoContext();

                using (var ctxIts = new ITSolutionContext())
                {
                    ctxIts.LazyLoading(false);
                    ctxIts.LembreteDao.Find(1);
                }


                //apenas invoca o mesmo para criação das tabelas
                using (var ctxRpt = new ReportContext())
                {
                    ctxRpt.LazyLoading(false);
                    ctxRpt.ReportGroupDao.Find(1);
                }

                using (var ctxCambio = new CambioContext())
                {
                    ctxCambio.LazyLoading(false);
                    ctxCambio.MoedaDao.Find(1);
                }
            }
            catch (Exception ex)
            {
                XMessageIts.ExceptionJustMessage(ex, "Falha na inicialização do controlador do contexto!", "Falha no Sistema");
                Application.Exit();
                Environment.Exit(0);
            }

            return(_ctx);
        }