Skip to content

Instantly share code, notes, and snippets.

@codehaks
Created July 1, 2020 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codehaks/672d7cc6d9df0ea5c99dc80874b510d3 to your computer and use it in GitHub Desktop.
Save codehaks/672d7cc6d9df0ea5c99dc80874b510d3 to your computer and use it in GitHub Desktop.
Expression-Bodied Members
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