Skip to content

Instantly share code, notes, and snippets.

@cphillips83
Last active August 16, 2017 15:53
Show Gist options
  • Save cphillips83/2f24e7631b6c49834c2a2a5664ac7d80 to your computer and use it in GitHub Desktop.
Save cphillips83/2f24e7631b6c49834c2a2a5664ac7d80 to your computer and use it in GitHub Desktop.
{
var q0 = dc.Contacts
.Where(x => x.ID > 1 && x.Status == EntityStatus.Active)
.OrderByDescending(x => x.ID)
.Select(x => new { x.ID, x.Status });
var c0 = q0.FirstOrDefault();
Console.WriteLine(c0);
}
{
var q1 = from x in dc.Contacts
where x.ID > 1 && x.Status == EntityStatus.Active
orderby x.ID descending
select new { x.ID, x.Status };
var c1 = q1.FirstOrDefault();
Console.WriteLine(c1);
}
{
var q2 = from x in dc.Contacts
where x.ID > 1 && x.Status == EntityStatus.Active
orderby x.ID descending
select x;
var c2 = q2.FirstOrDefault();
Console.WriteLine(c2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment