Visual Studio 2008之语言特性 查询语法.docVIP

  1. 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Visual Studio 2008之语言特性 查询语法

Visual Studio 2008之语言特性 查询语法 2007-11-14 10:02作者:韩现龙的博客出处:天极网软件频道责任编辑:幽灵   If instead of returning Person objects, I wanted to return just the firstnames of the people in the collection, I could re-write my query like so:   如果我不返回一个Person对象,只想返回collectioin中所有人的名字的集合,可以按照如下方式重写该查询语句:      Note above how I am no longer saying select p, but am instead saying select p.FirstName. This indicates that I dont want to return back a sequence of Person objects - but rather I want to return a sequence of strings - populated from each Person objects FirstName property (which is a string). The datatype result of this query syntax expression is consequently of type IEnumerable.   注意上边我没再用“select p,而是用select p.FirstName。这表明我不想让查询返回Person对象,而是想返回一个字符串--这个字符串是Person这个对象的FirstName属性(是个字符串)中取得的。因此,该查询表达式返回值的数据类型是IEnumerable。   Sample Query Syntax Against a Database   关于对数据库查询的事例:   The beauty of LINQ is that I can use the exact same query syntax against any type of data. For example, I could use the new LINQ to SQL object relational mapper (ORM) support provided in Orcas to model the SQL Northwind database with classes like below (please watch my video here to learn how to-do this):   LINQ的美在于我可以对任何类型的数据使用完全一致的查询语法。比如,我可以用在Orcas中提供的新的LINQ to SQL ORM来构建SQL 的Northwind数据库,如下图:((请看我的视频来学习如何做:watch my video here ):      Once Ive defined the class model above (and its mapping to/from the database), I can then write a query syntax expression to fetch all products whose unitprice is greater than $99:   一旦我定义了如上的类模型(和它的 从/向 数据库中绘制出来的图),我可以写一个查询语句,查找出unitprice比99$多的产品来:      In the above code snippet I am indicating that I want to perform a LINQ query against the Products table on the NorthwindDataContext class created by the ORM designer in Visual Studio Orcas. The select p indicates that I want to return a sequence of Product objects that match my query. The datatype result of this query syntax expression is consequently of type IEnumerable.   在上边的代码片断中,我指明了我想对用ORM设计器生成的NorthwindDataContext类的Pr

文档评论(0)

jgx3536 + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

版权声明书
用户编号:6111134150000003

1亿VIP精品文档

相关文档