Beispiel #1
0
 public void Remove(params T[] items)
 {
     using (var context = new CareerCloudContext())
     {
         foreach (T item in items)
         {
             context.Entry(item).State = EntityState.Deleted;
         }
         context.SaveChanges();
         context.Dispose();
     }
 }
Beispiel #2
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);
        }
Beispiel #3
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);
        }