Esempio n. 1
0
        public void OgrenciIslem()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    Monitor.Enter(this);
                    CoarseGrainedLockEntities db         = new CoarseGrainedLockEntities();
                    List <Ogrenci>            ogrenciler = db.Ogrenci.ToList();

                    foreach (var ogrenci in ogrenciler)
                    {
                        ogrenci.OgrenciAdi = "Hasan3";
                        List <Ders> aldigiDersler = ogrenci.Ders.ToList();

                        foreach (var aldigiDers in aldigiDersler)
                        {
                            aldigiDers.DersAdi = aldigiDers.DersAdi + " Değişen ders adi";
                        }
                    }
                    db.SaveChanges();

                    ts.Complete();
                }
                catch (Exception ex)
                {
                    throw new Exception("Bir hata oluştu");
                }
                finally
                {
                    Monitor.Exit(this);
                }
            }
        }
        public void OgrenciIslem()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    Monitor.Enter(this);
                    CoarseGrainedLockEntities db = new CoarseGrainedLockEntities();
                    List<Ogrenci> ogrenciler = db.Ogrenci.ToList();

                    foreach (var ogrenci in ogrenciler)
                    {
                        ogrenci.OgrenciAdi = "Hasan3";
                        List<Ders> aldigiDersler = ogrenci.Ders.ToList();

                        foreach (var aldigiDers in aldigiDersler)
                        {
                            aldigiDers.DersAdi = aldigiDers.DersAdi + " Değişen ders adi";
                        }
                    }
                    db.SaveChanges();
                    
                    ts.Complete();
                }
                catch (Exception ex)
                {
                    throw new Exception("Bir hata oluştu");
                }
                finally
                {
                    Monitor.Exit(this);
                }
            }
        }