Linq To Expression Kodları ve Örnekleri | aliyasindogan.com
LINQ TO EXPRESSION KODLARI VE ÖRNEKLERİ

LINQ TO SQL | Ali Yasin Doğan | 01.11.2016 | 3088

Linq To Expression Kodları ve Örneklerini Sizlerle Paylaşacağım.

  
 //DB Bağlantısı
        OkulDataContext db = new OkulDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            //OgrenciSayisi
            lblOgrenciSayisi.Text = db.Ogrenci_Tbls.Count().ToString();

            //Ogrenci_Tbl Tablosunda Veri Varmı ? Kontrolü
            bool VarMi = db.Ogrenci_Tbls.Any();
            if (VarMi)
            {
                lblKontrol.Text = "Veri Mevcut !";
            }
            else
            {
                lblKontrol.Text = "Veri Mevcut Değil !";
            }
            //Ogrenci_Tbl Tablosunda Tüm Verileri GridView'e Aktarma 
            GridView1.DataSource = db.Ogrenci_Tbls.ToList();
            GridView1.DataBind();

            //Ogrenci_Tbl Tablosunda OgretmenID si 6 olanları GridView'e Aktar
            GridView2.DataSource = db.Ogrenci_Tbls.Where(x => x.OgretmenID == 6).ToList();
            GridView2.DataBind();

            //OgrenciId si 1 olan Öğrencinin adı
            lblOgrenciAdSoyad.Text = db.Ogrenci_Tbls.FirstOrDefault(p => p.OgrenciId == 1).OgrenciAdSoyad;
        }

Linq-To-Expression-Kodlari-ve-ornekleri




 Etiketler:  linq to expression linq to sql