예제 #1
0
        /// <summary>
        /// Saves the import data.
        /// </summary>
        /// <param name="importZipCodes">The import zip codes.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void SaveImportData(IEnumerable <tCustomizeTopic> importTest)
        {
            try
            {
                ////先砍掉全部資料
                //using (var db = new dbTeam2_FinalEntities())
                //{
                //    foreach (var item in db.tCustomizeTopic.OrderBy(x => x.種類))
                //    {
                //        db.tCustomizeTopic.Remove(item);
                //    }
                //    db.SaveChanges();
                //}

                //再把匯入的資料給存到資料庫
                using (var db = new dbTeam2_FinalEntities())
                {
                    foreach (var item in importTest)
                    {
                        db.tCustomizeTopic.Add(item);
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #2
0
 public MRepository()
 {
     db      = new dbTeam2_FinalEntities();
     dbTable = db.Set <Table>();
 }