コード例 #1
0
ファイル: CustomerDB.cs プロジェクト: caseygruse/HondaFinder
        public static void Delete(int id)
        {
            var      context = new HondaDBContext();
            Customer c       = context.Customers.Find(id);

            context.Customers.Remove(c);
            context.SaveChanges();
        }
コード例 #2
0
ファイル: CustomerDB.cs プロジェクト: caseygruse/HondaFinder
        public static void AddCustomer(Customer c)
        {
            //create db
            HondaDBContext context = new HondaDBContext();

            //add customer c to database
            context.Customers.Add(c);
            //save changes
            context.SaveChanges();
        }
コード例 #3
0
        /// <summary>
        /// adds a Vehical Object to the dataBase
        /// </summary>
        /// <param name="v"></param>
        public static void AddVehicle(Vehicle v)
        {
            //creates db context
            HondaDBContext context = new HondaDBContext();

            //adds the the object to database
            context.Vehicles.Add(v);
            //saves the changes
            context.SaveChanges();
        }
コード例 #4
0
ファイル: CustomerDB.cs プロジェクト: caseygruse/HondaFinder
        //public static bool CheckForCustomerID(int id)
        //{
        //	HondaDBContext context = new HondaDBContext();
        //	try
        //	{
        //		context.Customers.Find(id);
        //	}
        //}

        public static void Update(Customer c)
        {
            HondaDBContext context = new HondaDBContext();

            //tell EF this product has only been modified
            //its already in the db
            context.Entry(c).State = EntityState.Modified;

            //sends update query to the database
            context.SaveChanges();
        }