using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AlfredoLotar.Livro.Aspnet.SchoolModel;
using System.Data.Objects;
using System.Data.Common;

public partial class OrderBy : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void bntExecutar_Click(object sender, EventArgs e)
    {
        using (SchoolEntities contexto = new SchoolEntities())
        {
            /*IQueryable<Person> p = contexto.Person.OrderBy("it.FirstName");
            foreach (Person reg in p)
            {
                Response.Write(reg.FirstName + " ");
                Response.Write(reg.LastName + "<p/>");
            }
            */
            ObjectQuery<DbDataRecord> p = contexto.Person.Select("it.FirstName, it.LastName");
            foreach (DbDataRecord reg in p.OrderByDescending(reg => reg))
            {
                Response.Write(reg["FirstName"].ToString() + " ");
                Response.Write(reg["LastName"].ToString() + "<p/>");
            }
        }
    }
}