C#英语笔记Day 28

1.词汇

  • the sake of talking to databases 和数据库的交互能力

2.例句

  • This looks remarkably like SQL.

    这看起来有点像SQL的风格。

  • Indeed, the reaction of many people on first hearing about LINQ is to reject it as merely trying to put SQL into the language for the sake of talking to databases.

    事实上,许多人第一次听说LINQ时的第一反应是我是拒绝的,以为它只是简单的把SQL语言引入进来增强与数据库的交互能力。

  • Fortunately, LINQ has borrowed the syntax and some ideas from SQL, but as you’ve seen, you needn’t be anywhere near a database in order to use it. .

    幸运的是,LINQ只是借鉴了sql的语法和思路,正如我们看见的,没有数据库也可以使用它。

3.代码

  • 像SQL一样操作集合,有where关键字等等
List<Product> products = Product.GetSampleProducts();
List<Supplier> suppliers = Supplier.GetSampleSuppliers();
var filtered = from p in products
               join s in suppliers
                  on p.SupplierID equals s.SupplierID
               where p.Price > 10
               orderby s.Name, p.Name
               select new { SupplierName = s.Name, ProductName = p.Name };
foreach (var v in filtered)
{
   Console.WriteLine("Supplier={0}; Product={1}",
                     v.SupplierName, v.ProductName);
}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容