When it comes to dlinq, you have to say LINQ first. Let's see what LINQ is first. LINQ is the abbreviation for language Integrated query. So in fact DLinq is the abbreviation for Database Language Integrated query. The biggest difference between LINQ and DLinq is that it operates on memory with LINQ, while the DLinq action object is the database.
Let's take a look at a LINQ example first. Before that, you need to install the s2008 Beta2 version. can go to
http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx download. If your machine is vs2005 in English, you will also need to install a LINQ preview version. You can go to the following address to download.
http://www.microsoft.com/downloads/details.aspx?familyid=1e902c21-340c-4d13-9f04-70eb5e3dceea&displaylang= En
Microsoft also offers a lot of places to learn. Give a couple of links first.
http://msdn.microsoft.com/data/ref/linq/
Http://msdn.microsoft.com/data/ref/linq/default.aspx?pull=/library/en-us/dndotnet/html/linqprojectovw.asp
Http://msdn.microsoft.com/vcsharp/future/
OK, let's take a look at a LINQ example first. This example can be obtained from the documentation on LINQ.
The LINQ sample
1using System;
2using System.Query;
3using System.Collections.Generic;
4
5class app …{
6 static void Main() …{
7 string[] names = …{ "Burke", "Connor", "Frank",
8 "Everett", "Albert", "George",
9 "Harris", "David" };
10
11 IEnumerable<string> expr = from s in names
12 where s.Length == 5
13 orderby s
14 select s.ToUpper();
15
16 foreach (string item in expr)
17 Console.WriteLine(item);
18 }
19}
20
You may feel strange. At ease, this is probably the first time to see the reason. Here, like From,where,orderby, select, and so on, are LINQ reserved words that should be shown in blue, but it seems that Cnblogs has not yet begun to support it. So when you insert the code, they are treated as normal characters.
In fact, query expression looks like a SQL statement. For example, select * FROM table1 where column1 = "";
The first time I saw LINQ, I felt like a SQL statement written in a program. It's just that we used to form a SQL statement with a string type and upload it to SQL Server via command or adapter. Now, it feels like the SQL statement is implemented directly as a program code. This is just one of our illusions.
In this case, it simply extracts the length 5 from an array of string and capitalizes all the extracted data. Ienumerable<string> uses generics in the c#2.0. The result of this one, returns a dataset, which is stored in expr. Here, the result from that DataSet is expressed in, as shown in the column, from S in names, and in the names set, take out S. s represents a record. The where represents the condition, by which the order is sorted. Select those fields to make a variable. Here, you may find it strange that the S variables are declared there. I was surprised when I first saw it. In fact, the s variable is the element in the names variable, and you have declared the s variable when you are in names.
In this Liezi, you can first feel the LINQ, in the following chapters, I will introduce more to you. Querying the memory array does not show the Power of LINQ, and the operation of the database makes LINQ more practical. In the following chapters, I will introduce DLINQ's syntax gradually.