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); }
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); }
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); }
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); }
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); }