• Linq


    LINQ是什么?
    它是Language Integrated Query。
    当我们要对数据库表进行查询的时候,我们一定会编写 "select * from sometable where ID = .."的语句。好,那我们现在根据LINQ的语法,完全可以将我们熟悉的SQL中像"select","from","where"等语句在.NET Framework环境中顺利使用并且大大提高开发的效率。

    下面我就牛刀小试,做个demo看看。

    1. 先下载LinQ框架 
        现在最新版本是2006年5月发布"Orcas CTP", 下载地址(这里 )

    2. 下载安装待完毕。

    3. 新建一个"LINQ Console Application"项目。

    4. 输入代码如下:   

     1  using System;
     2  using System.Collections.Generic;
     3  using System.Text;
     4  using System.Query;
     5  using System.Xml.XLinq;
     6  using System.Data.DLinq;
     7  
     8  namespace LINQConsoleApplication1
     9 {
    10     class Program
    11     {
    12         static void Main(string[] args)
    13         {
    14             string[] aBunchOfWords = {"One","Two""Hello""World"
    15 
    16 "Four""Five"};
    17             var result = 
    18             from s in aBunchOfWords // query the string array 
    19             where s.Length == 5     // for all words with length = 5
    20             select s;               // and return the string
    21             foreach (var s in result) {
    22                 Console.WriteLine(s); //print
    23             }
    24         }
    25     }
    26 }


    运行结果如下:
    Hello
    World
    print any key to continue ...
  • 相关阅读:
    fopen & fcolse & fseek & ftell & fstat 文件操作函数测试
    python基础练习题30道
    2636652995 揭秘骗子qq
    python的异常处理try/except 万能处理exception
    类的装饰器的基本原理
    描述符的应用
    描述符
    组合的方式完成授权
    继承的方式完成包装__attr__
    类的内置方法__attr__介绍
  • 原文地址:https://www.cnblogs.com/abcdwxc/p/889983.html
Copyright © 2020-2023  润新知