MVC初体验-EF查询(Lambda的用法)(18)
2021-04-20 04:26
标签:匿名 匿名对象 lis HERE inf 对象 jquery image == 使用数据库:NorthWind示例数据库 (链接:https://www.cnblogs.com/liverpool/p/4718042.html) 后台代码: 前台代码: 显示效果: End MVC初体验-EF查询(Lambda的用法)(18) 标签:匿名 匿名对象 lis HERE inf 对象 jquery image == 原文地址:https://www.cnblogs.com/LeeSki/p/12261837.htmlnamespace T1_EF.Controllers
{
public class CustomersController : Controller
{
// GET: Customers
public ActionResult Index()
{
//NorthwindEntities northwind = new NorthwindEntities();
//var list = northwind.Customers.Select(c =>c);
//建议使用下面这种写法,面向抽象编程,使用多态,并且更灵活
//DbContext dbContext = new NorthwindEntities();
//var list = dbContext.Set
@model IEnumerableT1_EF.Models.Customers>
@*@model IEnumerableT1_EF.ViewModels.CustomerModel>*@
@{
Layout = null;
}
DOCTYPE html>
html>
head>
meta name="viewport" content="width=device-width" />
title>FuncTionIndextitle>
head>
body>
div>
table border="1">
tr>
td>联系人姓名td>
td>客户公司td>
td>客户属国td>
tr>
@foreach (var item in Model)
{
tr>
td>@item.ContactNametd>
td>@item.CompanyNametd>
td>@item.Countrytd>
tr>
}
table>
div>
body>
html>