Tracy.Bai

Focus on Data analysis and Mining

导航

Linq in action 学习笔记(一)

 

                                   第一章

什么是Linq

Linq的起源:在我们的编程过程当中,不得不处理各种各样的数据。There is a gap between your programming language and relation database.mismatch)在编程语言和关系型数据库之间存在着一定的不匹配。曾经有通过面向对象的数据库来解决此问题,但是关系数据库一直还是pervasive(普遍深入的)。

   Linq的最根本的动机是address conceptual and techenology difficiulty encounted 在使用.net 语言访问数据库。微软的用linq的意图是通过对象关系映射来提供这个问题的解决方案,还有简化对象和数据源之间的交互。

Linq overview

Linq 的第一个重要之处在于linq被设计成可以来应付任何一种类型,以及提供了一致的编程模型。

Linq的另外一个重要之处是Linq是强类型化的,它能够在编译时核查查询以及visual studio的智能支持。

Linq as a toolset

  

Linq as language extension

这是linq的第一个例子。

我们为什么需要Linq

 

Common problem

我们用.net访问数据库:

Linq

 

13

 

Object-relationship mapping

The mismatch exsits several levels;

First the data type;

Second the different data model;the relation database use datatable and relationship;and the object model use inheritance,composite.and

Third programming model

 

Linq to rescue

Linq remove the barriers between the database ,xml and objects.it enables us to work with these paradigms using Linq.for example, we are able to work with the xml data file and the data coming from the database within the same query.

 

 

The goals of Linq

 

24

First review of Linq to objects

If you don’t use Linq ,the code like this:

现在 我们在想,这样并不能体现Linq的优势来,上面的代码可以说更简洁。但是请看以下代码,将能体现Linq的优越性来:

Linq 也能够提供统计的功能。

 

First review to Linq to xml.

我相信下图能够体现出Linq to xml的好处来。

For example;

而使用System.Xml的类库处理方法如下:

 

Linq to sql

我们对它都比较熟悉了,让我们还是来看看它的优点把:

 

posted on 2008-08-18 22:35  Love Fendi  阅读(271)  评论(0编辑  收藏  举报