zoukankan      html  css  js  c++  java
  • LINQ 小解

    LINQ to Objects

    LINQ to ADO.NET -|-LINQ to SQL
                     |-LINQ to DataSet
                     |-LINQ to Entiries
    LINQ to XML


    (SOAP)Simple Object Access Protocol 

    LINQ to Object
    LINQ query that gets temporary files greater than 10,000 bytes, ordered by size

                 string tempPath = Path.GetTempPath();
                 DirectoryInfo dirInfo = new DirectoryInfo( tempPath );
                 var query =
                      from     f in dirInfo.GetFiles()
                      where   f.Length > 10000
                      orderby f.Length descending
                      select   f;

    LINQ to ADO.NET
     LINQ to ADO.NET includes different LINQ implementations that share the need to manipulate
              relational data. It includes other technologies that are specific to each particular persistence layer:

                ■    LINQ to SQL     Handles the mapping between custom types in C# and the physical table
                    schema.

                ■    LINQ to Entities   Is in many ways similar to LINQ to SQL. However, instead of using the
                    physical database as a persistence layer, it uses a conceptual Entity Data Model (EDM).
                    The result is an abstraction layer that is independent from the physical data layer.

                ■    LINQ to DataSet     Makes it possible to query a DataSet using LINQ.

     LINQ to SQL and LINQ to Entities have similarities because they both access information
              stored in a relational database and operate on object entities that represent external data in
              memory. The main difference is that they operate at a different level of abstraction. While
              LINQ to SQL is tied to the physical database structure, LINQ to Entities operates over a con-
              ceptual model (business entities) that might be far from the physical structure (database
              tables).

              The reason for these different options for accessing relational data through LINQ is that
              different models for database access are in use today. Some organizations implement all access
              through stored procedures, including any kind of database query, without using dynamic
              queries. Many others use stored procedures to insert, update, or delete data and dynamically
              built SELECT statements to query data. Some see the database as a simple object persistence
              layer, while others put some business logic into the database using triggers, stored proce-
              dures, or both. LINQ tries to offer help and improvements in database access without forcing
              everyone to adopt a single comprehensive model.
    LINQ to XML

              LINQ to XML offers a slightly different syntax that operates on XML data, allowing query and
              data manipulation. A particular type of support for LINQ to XML is offered by Visual Basic
              9.0, which includes XML literals in the language. This enhanced support simplifies the code
              necessary to manipulate XML data. In fact, you can write such a query in Visual Basic 9.0:

              Dim book = _
                  <Book Title="Introducing LINQ">
                       <%= From person In team _
                           Where person.Role = "Author" _
                           Select <Author><%= person.Name %></Author> %>
                  </Book>

              This query corresponds to the following C# 3.0 syntax:

              dim book =
                  new XElement( "Book",
                       new XAttribute( "Title", "Introducing LINQ" ),
                       from   person in team
                       where  person.Role == "Author"
                       select new XElement( "Author", person.Name ) );

  • 相关阅读:
    Java Varargs 可变参数使用
    GitLab 如何删除 Forked from
    Git Clone 的时候遇到 Filename too long 错误
    Spring Boot 如何部署到 Linux 中的服务
    Gradle 如何打包 Spring Boot 如何不添加版本代码
    HDU 5878---预处理+二分查找
    HDU 5881--Tea 思维规律
    HDU 5879---cure
    (转)C/S 与 B/S 区别
    卡特兰数
  • 原文地址:https://www.cnblogs.com/williamzhao/p/2410618.html
Copyright © 2011-2022 走看看