예제 #1
0
        public static async Task UpdateScCompInfoAsync()
        {
            using (var db = new WebDbContext())
            {

                var compinfo = await db.ScCompInfoes.FindAsync(6);
                if (compinfo != null)
                {
                    compinfo.CompNm = "업데이트111";
                }
                else
                {
                    var comp = new ScCompInfo
                    {
                        Addr1 = "테스트업데이트주소",
                        CompNm = "업데이트당ㅇ앙아앙아",
                        CompType = "A"
                    };

                    db.ScCompInfoes.Add(comp);
                }

                await db.SaveChangesAsync();

            }
        }
예제 #2
0
        public static async void UpdateCompInfoMultiAsync()
        {
            using (var db = new WebDbContext())
            {
                var comps = db.ScCompInfoes.Where(ci => ci.CompType == "A" && ci.CompNm == "test113").ToList();

                comps.ForEach(cis =>
                {
                    cis.Email = "*****@*****.**";
                });

                await db.SaveChangesAsync();
            }
        }
예제 #3
0
        public  static async void insertScCompInfoAsync()
        {
            var comp = new ScCompInfo
            {
                Addr1 = "테스트주소",
                CompNm = "테스트회사",
                CompType = "A"
            };

            using (var db = new WebDbContext())
            {

                db.ScCompInfoes.Add(comp);

                //이것도 가능
                //db.Entry<ScCompInfo>(comp).State = System.Data.Entity.EntityState.Added;

                await db.SaveChangesAsync();
            }
        }