zoukankan      html  css  js  c++  java
  • 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 ...
  • 相关阅读:
    创业感悟:工程师的自我突破
    如何向Openstack社区提交一个新项目
    Advacned Puppet: Puppet Master性能调优
    Mysql Join语法解析与性能分析
    git初体验(七)多账户的使用
    (2):Mysql 查看、创建、更改 数据库和表
    博客索引
    双声道合并为单声道
    树莓派命令行配置无线网络
    树莓派安装Ubuntu系统
  • 原文地址:https://www.cnblogs.com/abcdwxc/p/889983.html
Copyright © 2011-2022 走看看