g => g.Name == genre代表一个匿名函数。即这里向Single方法传入了一个方法类型的参数。

=>左边的g代表方法的参数,可以有多个,如(g,f) => ...,=>右边代表方法的返回值,
写全了是这样的:g => { return g.Name }。
里之所以能点出Name属性,是因为Single方法声明了这个方法类型参数的格式,比如:
Func<Student, bool>
这个方法类型指示输入参数是Student类型,返回值是bool类型。对应于上面的方法参数值,
那么g代表Student对象,g可以随便命名,但这里总是代表Student对象,比如可以写成:
Single(stu => stu.Name == ”genre“);
在Single方法内部,它就可以调用我们传入的这个方法,它传入Student类型参数,
那么就会返回一个bool值来代表该对象是否满足Name属性等于"genre"这个条件,以此在遍历Student列表的时候过滤数据。

var genreModel =storeDB.Genres.Include("Albums").Single(g => g.Name == genre);是什么意思?的更多相关文章

  1. linq 获取不重复数据,重复数据 var unique = arr.GroupBy(o => o).Where(g => g.Count() == 1) .Select(g => g.ElementAt(0));

    static void Main(string[] args) { int[] arr = { 1, 3, 3, 3, 3, 4, 5, 4, 5, 8, 9, 3 }; //不重复 var uniq ...

  2. G - G ZOJ - 2723 (素数打表+set)

    Prime Number Definition An integer greater than one is called a prime number if its only positive di ...

  3. The 11th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Ternary Calculation

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3782 题意:把输入的三元运算用计算机运算出来. ;          ci ...

  4. sed,n,N,d,D,p,P,h,H,g,G,x,解析

    原文地址 这篇文章主要是我参考命令的,直接复制粘贴,有问题请拍砖 A. sed执行模板=sed '模式{命令1;命令2}' 即逐行读入模式空间,执行命令,最后输出打印出来 B. p打印当前模式空间所有 ...

  5. MvcMusicStore学习中常出现的一个BUG

    BUG描述:var genreModel = storeDB.Genres.Include("Albums").Single(g => g.Name == genre); 前 ...

  6. ASP.NET MVC 音乐商店 - 4. 数据访问

    上一次,我们使用了模拟的数据从控制器发送到视图模板.现在,我们开始使用真正的数据库,在这个教程中,我们将指导如何使用 SQL Server Compact 版的数据库,它经常被称为 SQL CE, 来 ...

  7. MVC3 学习总结一(未发布)

    MVC:  Model,View,Control   设置View中的数据 1. 返回model,View中强类型化 Control: public ActionResult Browse(strin ...

  8. Microsoft MVC3 框架

             1. 安装MVC3框架 官网:http://www.asp.net/mvc 下载:ASP.NET MVC3 with Tools http://go.microsoft.com/fw ...

  9. ASP.NET MVC 3 之表单和 HTML 辅助方法(摘抄)

    ——选自<ASP.NET MVC3 高级编程(第5章) 孙远帅 译> 第5章 表单和HTML辅助方法 本章内容简介: * 理解表单 * 如何利用HTML辅助方法 * 编辑和输入的辅助方法 ...

随机推荐

  1. COJ 0332 The Flash

    传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=302 The Flash 难度级别:B: 运行时间限制:1000ms: 运行 ...

  2. -_-#toFixed

    parseFloattoFixed

  3. 飘窗代码修改了一段js

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. Binary Search Tree Iterator——LeetCode

    Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the ro ...

  5. LeetCode——Pascal's Triangle

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  6. HDU 4627 There are many unsolvable problem in the world.It could be about one or about zero.But this time it is about bigger number.

    题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82974#problem/E 解题思路:数论,从一个数的中间开始往两边找,找到两 ...

  7. 深度优先搜索-linux上浅显易懂的例子

    上次看啊哈算法中的深度优先搜索,自己用的是linux(linux粉,windows黑,嘿嘿),字符界面,为了强化对这个的理解,就在linux上对这个例子的代码做了一点修改可以很清楚的看到整个搜索过程, ...

  8. 关于Android API的理解

    举个例子: 比如程序中用到了android.content.ClipboardManager这个类, 而该类是在API 11才添加到 “库”. (原谅我,不理解Google API 文档里的 adde ...

  9. KVM几种缓存模式

    原文在这里: http://pic.dhe.ibm.com/infocenter/lnxinfo/v3r0m0/index.jsp?topic=%2Fliaat%2Fliaatbpkvmguestca ...

  10. 在网页中在线浏览ppt文档

    方法一: 把ppt文件的扩展名直接修改为pps,嵌入到网页中 缺点:这种方式浏览器会提示是打开,还是下载,选择打开的话会直接在浏览器中打开,并且客户端一定要安装Office PowerPoint才能打 ...