Beispiel #1
0
 public void Delete <T>(decimal id1, decimal id2) where T : class
 {
     using (OlimpiadaDBEntities db = new OlimpiadaDBEntities())
     {
         T entity = db.Set <T>().Find(id1, id2);
         db.Set <T>().Remove(entity);
         db.SaveChanges();
     }
 }
Beispiel #2
0
 public void Delete <T>(T entity) where T : class
 {
     using (OlimpiadaDBEntities db = new OlimpiadaDBEntities())
     {
         //T entity = db.Set<T>().Find(id);
         db.Set <T>().Remove(entity);
         db.SaveChanges();
     }
 }
Beispiel #3
0
 public T Create <T>(T objeto) where T : class
 {
     using (OlimpiadaDBEntities db = new OlimpiadaDBEntities())
     {
         db.Set <T>().Add(objeto);
         db.SaveChanges();
     }
     return(objeto);
 }
Beispiel #4
0
        public T FindById <T>(IdT Id) where T : class
        {
            T objeto;

            using (OlimpiadaDBEntities db = new OlimpiadaDBEntities())
            {
                objeto = db.Set <T>().Find(Id);
            }
            return(objeto);
        }
Beispiel #5
0
        public IList <T> FindAll <T>() where T : class
        {
            IList <T> objeto = new List <T>();

            using (OlimpiadaDBEntities db = new OlimpiadaDBEntities())
            {
                var lst = (from e in db.Set <T>() select e);

                objeto = lst.ToList <T>();
            }
            return(objeto);
        }