示例#1
0
        public virtual C Get(Expression <Func <C, bool> > where)
        {
            C item = null;

            using (var context = new DB_PASTEBOOKEntities())
            {
                item = context.Set <C>().Where(where).FirstOrDefault();
            }

            return(item);
        }
示例#2
0
        public virtual List <C> GetAll()
        {
            List <C> getAll = new List <C>();

            using (var context = new DB_PASTEBOOKEntities())
            {
                getAll = context.Set <C>().AsNoTracking().ToList <C>();
            }

            return(getAll);
        }
示例#3
0
        public virtual string Get(Expression <Func <C, bool> > where, Func <C, string> selectProperty)
        {
            string returnValue = string.Empty;

            using (var context = new DB_PASTEBOOKEntities())
            {
                returnValue = context.Set <C>().Where(where).Select(selectProperty).FirstOrDefault();
            }

            return(returnValue);
        }
示例#4
0
        public virtual List <C> GetList(Expression <Func <C, bool> > where)
        {
            List <C> getList = new List <C>();

            using (var context = new DB_PASTEBOOKEntities())
            {
                getList = context.Set <C>().AsNoTracking()
                          .Where(where).ToList();
            }

            return(getList);
        }
示例#5
0
        public virtual bool Remove(Expression <Func <C, bool> > where)
        {
            bool returnValue = false;

            using (var context = new DB_PASTEBOOKEntities())
            {
                var item = context.Set <C>().Where <C>(where).FirstOrDefault();
                context.Entry(item).State = EntityState.Deleted;
                returnValue = context.SaveChanges() != 0;
            }

            return(returnValue);
        }