Ejemplo n.º 1
0
        public async Task <IEnumerable <Extrato> > GetByQueryAsync(string query)
        {
            using (var context = new WpFinanceiroContext())
            {
                var result = await context.Set <Extrato>().FromSql(query).ToListAsync();

                return(result);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Busca todos itens salvo na base
        /// </summary>
        /// <param name="navigationProperties">Classe operante</param>
        /// <returns>Lista baseada no tipo passado</returns>
        public virtual IList <T> GetAll()
        {
            List <T> list;
            var      context = new WpFinanceiroContext();

            IQueryable <T> dbQuery = context.Set <T>();


            list = dbQuery
                   .ToList <T>();

            return(list);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Usado para pegar todos utilizando Lambda Expression
        /// </summary>
        /// <param name="where">Sintaxe where para selecionar uma clausula</param>
        /// <param name="navigationProperties">Classe Operante</param>
        /// <returns>Lista filtrada</returns>
        public virtual IList <T> GetList(Func <T, bool> where,
                                         params Expression <Func <T, object> >[] navigationProperties)
        {
            List <T>       list    = new List <T>();
            var            context = new WpFinanceiroContext();
            IQueryable <T> dbQuery = context.Set <T>().AsQueryable();

            var query = context.Set <T>().AsQueryable();

            //Apply eager loading

            foreach (Expression <Func <T, object> > navigationProperty in navigationProperties)
            {
                dbQuery = dbQuery.Include <T, object>(navigationProperty);
            }

            list = dbQuery
                   .AsNoTracking()
                   .Where(where)
                   .ToList <T>();


            return(list);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="where"></param>
        /// <param name="navigationProperties"></param>
        /// <returns></returns>
        public virtual T GetSingle(Func <T, bool> where,
                                   params Expression <Func <T, object> >[] navigationProperties)
        {
            T              item    = null;
            var            context = new WpFinanceiroContext();
            IQueryable <T> dbQuery = context.Set <T>();

            //Apply eager loading
            foreach (Expression <Func <T, object> > navigationProperty in navigationProperties)
            {
                dbQuery = dbQuery.Include <T, object>(navigationProperty);
            }

            item = dbQuery
                   .AsNoTracking()         //Don't track any changes for the selected item
                   .FirstOrDefault(where); //Apply where clause

            return(item);
        }