Home > Software engineering >  Sort dynamic model with orderby
Sort dynamic model with orderby

Time:05-10

I am combining 2 tables that I transferred to the dynamic model into 1 table in the cshtml part.

And I want to sort that table by a column(OrderBy). How can I do that? I will be glad if you help. (Stackoverflow is pushing me to write more text, but I don't know what more to say about this topic. How can I fix?)

[HttpPost]
    public ActionResult GAdiSoyadiSirala()
    {
        var person = db.Personeller.ToList();
        var girisCikis = db.GirisCikisTarihleri.ToList();
        //person = person.OrderBy(x => x.AdiSoyadi).ToList();


        dynamic mymodel = new ExpandoObject();
        mymodel.Personel = person;
        mymodel.GirisCikis = girisCikis;

        
        return View("GirisCikislar", mymodel);
    }


//The part where I call the GirisCikislar view
public ActionResult GirisCikislar()
    {
        var person = db.Personeller.ToList();
        var girisCikis = db.GirisCikisTarihleri.ToList();


        dynamic mymodel = new ExpandoObject();
        mymodel.Personel = person;
        mymodel.GirisCikis = girisCikis;
        return View(mymodel);
    }

GirisCikislar.cshtml:

    @using PersonelTakipMVC.Models;
    @model dynamic

<table >
<tr>

    <th>PersonelID</th>



    @*<th>Adı Soyadı</th>*@
    <th>
//When I click this button, the GAdiSoyadiSirala method works.
        @using (Html.BeginForm("GAdiSoyadiSirala", "Home", FormMethod.Post))
        {
            <button >Adı Soyadı           
  • Related