Created
July 1, 2020 08:24
-
-
Save codehaks/672d7cc6d9df0ea5c99dc80874b510d3 to your computer and use it in GitHub Desktop.
Expression-Bodied Members
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Mvc; | |
using MyProfile.Common; | |
using PeopleApp.Common; | |
using PeopleApp.Data; | |
using System; | |
using System.Linq; | |
using System.Linq.Expressions; | |
namespace PeopleApp.Controllers | |
{ | |
public class HomeController : Controller | |
{ | |
private readonly PeopleDbContext _db; | |
public HomeController(PeopleDbContext db) => _db = db; | |
[Route("user/old/normal")] | |
public IActionResult Index() | |
=> Ok(_db | |
.Users | |
.Where(u => u.Age > 70) | |
.Select(u => new | |
{ | |
u.Givenname, | |
u.Surname, | |
u.Age, | |
u.Country | |
})); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment