Exemple #1
0
 public List <EntityHarley> GetAllHarleys()
 {
     using (GarageContext context = new GarageContext())
     {
         return(context.Harleys.ToList());
     }
 }
Exemple #2
0
        //methode delete

        public void Delete(EntityHarley Harley)
        {
            using (GarageContext context = new GarageContext())
                try
                {
                    context.Harleys.Attach(Harley);
                    context.Harleys.Remove(Harley);
                    context.SaveChanges();
                }
                catch
                {
                    throw;
                }
        }
Exemple #3
0
 //méthode create
 public void Create(EntityHarley Harley)
 {
     using (GarageContext context = new GarageContext())
     {
         try
         {
             context.Harleys.Add(Harley);
             context.SaveChanges();
         }
         catch
         {
             throw;
         }
     }
 }
Exemple #4
0
        //méthode update
        public void Update(EntityHarley Harley)
        {
            using (GarageContext context = new GarageContext())
            {
                try
                {
                    context.Harleys.Attach(Harley);
                    //On spécifie l'entité modifiée
                    context.Entry <EntityHarley>(Harley).State = EntityState.Modified;
                }

                catch
                {
                    throw;
                }
            }
        }