---
title: "How to use 'let' keyword in linq query mvc entity framework."  
description: "How to use 'let' keyword in linq query mvc entity framework."  
author: "Anonymous User"  
published: 2016-01-21  
updated: 2016-01-21  
canonical: https://www.mindstick.com/forum/33909/how-to-use-let-keyword-in-linq-query-mvc-entity-framework  
category: "asp.net mvc"  
tags: ["c#", "linq", "mvc", "entity framework"]  
reading_time: 1 minute  

---

# How to use 'let' keyword in linq query mvc entity framework.

I want to use 'let' [keyword in linq](https://www.mindstick.com/forum/33910/how-to-use-except-keyword-in-linq-query) [query](https://www.mindstick.com/blog/202/sub-query-in-sqlserver) [mvc](https://www.mindstick.com/forum/155803/define-cache-profile-in-mvc) [entity framework](https://www.mindstick.com/articles/1566/crud-operations-using-entity-framework-code-first-approach). how to do this please help me.

## Replies

### Reply by Anonymous User

The 'let' [keyword](https://www.mindstick.com/forum/33572/sql-inner-join-keyword) is useful in query syntax. It allows re-use of the expression and makes the query more readable.

```
@model IList<ForumMVC.CUSTOMER>@{    ViewBag.Title = "WebGrid CRUD Operations";   }<table style="background-color: #ccc; width:800px;">    <thead style="background-color: red;">        <tr>            <th>ID</th>             <th>Name</th>             <th>Phone</th>             <th>Email</th>                     </tr>    </thead>    <tbody style="background-color: #ddd;">        @foreach(var obj in Model)        {        <tr>            <th>@obj.CUST_ID</th>             <th>@obj.CUST_NAME</th>             <th>@obj.CUST_PHONE</th>             <th>@obj.CUST_EMAILID</th>                     </tr>        }    </tbody></table>
```

```
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using ForumMVC;using System.Data.Entity;using ForumMVC.Models;namespace ForumMVC.Controllers{    public class HomeController : Controller    {        forumEntities1 db = new forumEntities1();        public ActionResult Index()        {                      IList<CUSTOMER> data = (from s in db.CUSTOMER                                    let lowercaseCustomerName = s.CUST_NAME.ToLower()                                    where lowercaseCustomerName.EndsWith("singh")                                    select s).ToList();            return View(data);        }    }}
```

![How to use 'let' keyword in linq query mvc entity framework.](https://www.mindstick.com/mindstickforums/74d71cf7-64ab-4a5f-ac4d-9caeb0125a98/images/302ecd54-7824-49da-93b8-a5675224a9cf.png)


---

Original Source: https://www.mindstick.com/forum/33909/how-to-use-let-keyword-in-linq-query-mvc-entity-framework

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
