コード例 #1
0
        public static void deleteCompany(Company company)
        {
            try
            {
                using (db = new TIB_Model())
                {
                    db.Company.Attach(company);
                    db.Company.Remove(company);
                    db.SaveChanges();

                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        public static void saveCompany(Company company)
        {
            try
            {
                using (db = new TIB_Model())
                {
                    if (company.Id != 0)
                    {
                        db.Company.Attach(company);
                        db.Entry(company).State = EntityState.Modified;
                    }
                    else
                    {
                        db.Company.Add(company);
                    }

                    db.SaveChanges();
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }