1-DropDownList MCV
1.adim class Ogrenci
{
public int ID { get; set; }
public string Adi { get; set; }
}
2.adim List<Ogrenci> Ogrenciler = new List<Ogrenci>
{
new Ogrenci { ID = 1, Adi = "Gençay" },
new Ogrenci { ID = 2, Adi = "Selman" },
new Ogrenci { ID = 3, Adi = "Kübra" },
new Ogrenci { ID = 4, Adi = "Tuğba" },
new Ogrenci { ID = 5, Adi = "Seda" }
};
ViewBag.Ogrenciler = new SelectList(Ogrenciler, "ID", "Adi");
return View();
3.adim @Html.DropDownList("Ogrenciler", "Lütfen bir öğrenci seçiniz...")
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Query in Controller1
public string GetNameById()
{
var query = from a in db.Products
where a.ProductID ==1
select a.ProductName;
return query.FirstOrDefault();
}
Query in Controller2
public string GetNameById()
{
var query = from a in db.Products
where a.ProductID ==1
select a.ProductName;
return query.FirstOrDefault();
}
Query in Controller3
var result1 = context.kullanicis.Where(x=>x.id > 5);
var result2 = context.kullanicis.Where(x => x.id > 10 && x.adi == "ahme
Nortwind Query in Controller4
string str=null;
List<Category> categories = db.Categories.OrderBy(c => c.CategoryName).ToList();
foreach (var item in categories)
{
str = str + " \n" + item.CategoryName;
}
return str;
Hiç yorum yok:
Yorum Gönder