Пример #1
0
 public void remove(params T[] items)
 {
     using (var context = new BankManagermentEntities())
     {
         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 System.Linq.Expressions.Expression <Func <T, object> >[] navigationproperties)
        {
            T item = null;

            using (var context = new BankManagermentEntities())
            {
                IQueryable <T> dbquery = context.Set <T>();
                // eager loading
                foreach (Expression <Func <T, object> > navigationProperty in navigationproperties)
                {
                    dbquery = dbquery.Include <T, object>(navigationProperty);
                }
                item = dbquery.AsNoTracking().SingleOrDefault(where);
            }
            return(item);
        }
Пример #3
0
        public IList <T> GetList(Func <T, bool> where, params System.Linq.Expressions.Expression <Func <T, object> >[] navigationproperties)
        {
            List <T> list = null;

            using (var context = new BankManagermentEntities())
            {
                IQueryable <T> dbquery = context.Set <T>();
                // 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);
        }