Пример #1
0
 public void Remove(params T[] items)
 {
     using (var context = new BankManagementEntities())
     {
         foreach (T item in items)
         {
             context.Entry(item).State = System.Data.Entity.EntityState.Deleted;
         }
         context.SaveChanges();
     }
 }
Пример #2
0
        public T GetSingle(Func <T, bool> where, params Expression <Func <T, object> >[] navigationProperties)
        {
            using (var context = new BankManagementEntities())
            {
                IQueryable <T> dbquery = context.Set <T>();

                foreach (Expression <Func <T, object> > navigationProperty in navigationProperties)
                {
                    dbquery = dbquery.Include <T, object>(navigationProperty);
                }
                return(dbquery.AsNoTracking().Where <T>(where).SingleOrDefault <T>());
            }
        }
Пример #3
0
        public IList <T> GetList(Func <T, bool> where, params Expression <Func <T, object> >[] navigationProperties)
        {
            List <T> list = null;

            using (var context = new BankManagementEntities())
            {
                IQueryable <T> dbquery = context.Set <T>();

                foreach (Expression <Func <T, object> > navigationProperty in navigationProperties)
                {
                    dbquery = dbquery.Include <T, object>(navigationProperty);
                }
                list = dbquery.AsNoTracking().Where <T>(where).ToList <T>();
            }
            return(list);
        }
Пример #4
0
        public IList <T> GetAll(params Expression <Func <T, object> >[] navigationProperties)
        {
            List <T> list = null;

            using (var context = new BankManagementEntities())
            {
                context.Configuration.ProxyCreationEnabled = false;
                IQueryable <T> dbquery = context.Set <T>();

                foreach (Expression <Func <T, object> > navigationProperty in navigationProperties)
                {
                    dbquery = dbquery.Include <T, object>(navigationProperty);
                }
                list = dbquery.AsNoTracking().ToList <T>();
            }
            return(list);
        }