Exemplo n.º 1
0
        public IList <T> GetAll(params System.Linq.Expressions.Expression <Func <T, object> >[] navigationProperties)
        {
            IQueryable <T> query = _context.Set <T>();

            foreach (Expression <Func <T, object> > navProperty in navigationProperties)
            {
                query = query.Include <T, object>(navProperty);
            }
            return(query.ToList());
        }
        public IList <T> GetAll(params Expression <Func <T, object> >[] navigationProperties)
        {
            IQueryable <T> dbQuery = _context.Set <T>();

            foreach (Expression <Func <T, object> > property in navigationProperties)
            {
                dbQuery = dbQuery.Include <T, object>(property);
            }
            return(dbQuery.ToList <T>());
        }
        public IList <T> GetAll(params Expression <Func <T, object> >[] navigationProperties)
        {
            IQueryable <T> query = _context.Set <T>();

            foreach (var item in navigationProperties)
            {
                query = query.Include <T, Object>(item);
            }
            return(query.ToList());
        }
        public void Add(params T[] items)
        {
            _context.Set <T>();
            foreach (T item in items)
            {
                _context.Entry(item).State = EntityState.Added;
            }

            _context.SaveChanges();
        }
Exemplo n.º 5
0
        public IList <T> GetAll(params Expression <Func <T, object> >[] navigationProperties)
        {
            IQueryable <T> queryable = _context.Set <T>();

            foreach (var navprop in navigationProperties)
            {
                queryable = queryable.Include <T, object>(navprop);
            }
            return(queryable.ToList <T>());
        }
        public IList <T> GetAll(params Expression <Func <T, object> >[] navigationProperties)
        {
            IQueryable <T> query = _context.Set <T>();

            foreach (Expression <Func <T, object> > navProp in navigationProperties)
            {
                query = query.Include <T, object>(navProp);
            }
            // return query.Where  (a => a != null).ToList();
            return(_context.Set <T>().ToList());
        }
Exemplo n.º 7
0
        public IList <T> GetAll(params Expression <Func <T, object> >[] navigationProperties)
        {
            IQueryable <T> dbQuery = _context.Set <T>();

            foreach (var navprop in navigationProperties)
            {
                dbQuery = dbQuery.Include <T, object>(navprop);
            }
            return(dbQuery.ToList <T>());
            //throw new NotImplementedException();
        }
        // EF generic Repository
        public IList <SourceType> GetAll(params Expression <Func <SourceType, object> >[] navigationProperties)
        {
            IQueryable <SourceType> query = _context.Set <SourceType>();

            foreach (Expression <Func <SourceType, object> > navprop in navigationProperties)
            {
                query = query.Include <SourceType, object>(navprop);
            }

            return(query.ToList());
        }
        public IList <T> GetAll(params Expression <Func <T, object> >[] navigationProperties)
        {
            //Get my company poco as well as my company descriptons as well
            IQueryable <T> dbQuery = _context.Set <T>();

            foreach (Expression <Func <T, object> > navProp in navigationProperties)
            {
                dbQuery = dbQuery.Include <T, object>(navProp);
            }
            return(dbQuery.ToList()); // Done to sever cursor from database
        }
Exemplo n.º 10
0
        public IList <T> GetAll(params Expression <Func <T, object> >[] navigationProperties)
        {
            IQueryable <T> dbQuery = MyCareerCloudContext.Set <T>();

            foreach (var navProp in navigationProperties)
            {
                dbQuery = dbQuery.Include <T, object>(navProp);
            }
            return(dbQuery.ToList());

            //// ---Also works
            //  return MyCareerCloudContext.Set<T>().ToList<T>();
        }
        public T GetSingle(Expression <Func <T, bool> > where, params Expression <Func <T, object> >[] navigationProperties)
        {
            IQueryable <T> query = _context.Set <T>();

            foreach (Expression <Func <T, object> > navProp in navigationProperties)
            {
                query = query.Include <T, object>(navProp);
            }
            return(query.FirstOrDefault(where));
        }
Exemplo n.º 12
0
        public IQueryable <T> DbQuery(params Expression <Func <T, object> >[] navigationProperties)
        {
            IQueryable <T> dbQuery = _context.Set <T>();

            foreach (Expression <Func <T, object> > obj in navigationProperties)
            {
                dbQuery = dbQuery.Include <T, object>(obj);
            }
            return(dbQuery);
        }
        private IQueryable <T> GetRelatedRecord(params Expression <Func <T, object> >[] navigationProperties)
        {
            IQueryable <T> joinQuery = _currentcontext.Set <T>();

            foreach (Expression <Func <T, object> > property in navigationProperties)
            {
                joinQuery = joinQuery.Include <T, object>(property);
            }
            return(joinQuery);
        }
        public IList <T> GetAll(params System.Linq.Expressions.Expression <Func <T, object> >[] navigationProperties)
        {
            IList <T> result;

            using (var context = new CareerCloudContext(_createProxy))
            {
                IQueryable <T> dbQuery = context.Set <T>();
                foreach (var navigationProperty in navigationProperties)
                {
                    dbQuery = dbQuery.Include <T, object>(navigationProperty);
                }
                result = dbQuery.ToList();
            }
            return(result);
        }
        public T GetSingle(Func <T, bool> where, params System.Linq.Expressions.Expression <Func <T, object> >[] navigationProperties)
        {
            T result;

            using (var context = new CareerCloudContext(_createProxy))
            {
                IQueryable <T> dbQuery = context.Set <T>();
                foreach (var navigationProperty in navigationProperties)
                {
                    dbQuery = dbQuery.Include <T, object>(navigationProperty);
                }
                result = dbQuery.AsNoTracking().FirstOrDefault(where);
            }
            return(result);
        }
Exemplo n.º 16
0
        public T GetSingle(Expression <Func <T, bool> > where, params Expression <Func <T, object> >[] navigationProperties)
        {
            T item = null;

            using (var context = new CareerCloudContext())
            {
                IQueryable <T> dbQuery = context.Set <T>();

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

                item = dbQuery
                       .FirstOrDefault(where);
                context.Dispose();
            }
            return(item);
        }
Exemplo n.º 17
0
        public IList <T> GetAll(params Expression <Func <T, object> >[] navigationProperties)
        {
            List <T> list;

            using (var context = new CareerCloudContext())
            {
                IQueryable <T> dbQuery = context.Set <T>();

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

                list = dbQuery.ToList <T>();
                context.Dispose();
            }

            return(list);
        }
Exemplo n.º 18
0
        public IList <TPoco> GetAll(params Expression <Func <TPoco, object> >[] navigationProperties)
        {
            IQueryable <TPoco> dbQuery = default;

            try
            {
                using (var context = new CareerCloudContext())
                {
                    dbQuery = context.Set <TPoco>();
                    foreach (var navProp in navigationProperties)
                    {
                        dbQuery = dbQuery.Include <TPoco, object>(navProp);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception - {0}", ex);
            }
            return(dbQuery.ToList());
        }
Exemplo n.º 19
0
        public TPoco GetSingle(Expression <Func <TPoco, bool> > where, params Expression <Func <TPoco, object> >[] navigationProperties)
        {
            TPoco result = default;

            try
            {
                using (var context = new CareerCloudContext())
                {
                    IQueryable <TPoco> dbQuery = context.Set <TPoco>();
                    foreach (Expression <Func <TPoco, object> > navProp in navigationProperties)
                    {
                        dbQuery = dbQuery.Include <TPoco, object>(navProp);
                    }
                    result = dbQuery.Where(where).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception - {0}", ex);
            }
            return(result);
        }
Exemplo n.º 20
0
 public GenericRepository(CareerCloudContext _context)
 {
     this._context = _context;
     table         = _context.Set <T>();
 }
Exemplo n.º 21
0
 public GenericRepository(bool createProxy = true)
 {
     this._context = new CareerCloudContext(createProxy);
     table         = _context.Set <T>();
 }