Esempio n. 1
0
 public int GetCount(Expression <Func <T, bool> > predicate)
 {
     using (ABGNDBEntities context = new ABGNDBEntities())
     {
         return(context.Set <T>().Count(predicate));
     }
 }
Esempio n. 2
0
        public void Insert(T entity)
        {
            using (ABGNDBEntities context = new ABGNDBEntities())
            {
                context.Set <T>().Add(entity);
                context.Entry(entity).State = System.Data.Entity.EntityState.Added;

                context.SaveChanges();
            }
        }
Esempio n. 3
0
        public List <T> GetAll(Expression <Func <T, bool> > predicate = null)
        {
            using (ABGNDBEntities context = new ABGNDBEntities())
            {
                IQueryable <T> query = context.Set <T>();

                if (predicate != null)
                {
                    query = query.Where(predicate);
                }

                return(query.ToList());
            }
        }