Here I recommend to you a linqpad with this tool and skilled use can quickly learn and master LINQ
Installation steps:
Using LINQPad, you can easily debug LINQ and lambda expressions. It comes with LINQ and the F # simple Getting Started tutorial, linqpad whether you like it or not, anyway I like it, hehe. LINQPad is very compact and has only one EXE file that can be downloaded from http://www.linqpad.net. No nonsense, simple introduction of this tool, show the charm of the next linqpad, really very good.
First look at how to connect to the database, run LINQPad Press to operate,
Click Next to bring up the following screen,
Click OK after the interface below,
The following LINQ operations can be performed on a specific table,
You can then write the code in the edit window on the right,
Click on the different options will appear similar to the following interface,
linqpad:http://www.linqpad.net/
It also comes with a lot of examples to facilitate inquiries, LINQPad support object, Xml,sql, to LINQ here I only talk about SQL to LINQ
Many students do not know how to use LINQ to complete the left join, inner join, etc., here I use this tool for everyone to achieve
LINQPad will give us a lambda expression at the same time, SQL and IL I normally have a LINQ lambda, and when I do, I use LINQPad to debug the results.
Open its main page and look at it, click Addconnection to add a database connection
First build a library in the database Mydatademo two tables classes and student
Two tables built in the database
We select language as C # Expression in LINQPad's query tag, and connection Select data Mydatademo is the database we built above
Let's look at the left Join.
We enter the most basic LINQ expression point execution or F5 in the panel
From Stu in Studentsjoin Cla in Classeson Stu. class_id equals CLA. Class_idinto myjoinfrom grp in Myjoin.defaultifempty () select new {classid=grp. Class_id,class_name=grp. Class_name,st_name =stu. St_name}
Look at the results LINQPad showed us.
The SQL result is to judge whether our LINQ is correct
See it is left outer join (the left join IS left outer join and shorthand) proves that we are right
SELECT [T1]. [CLASS_ID] As [ClassId], [T1]. [Class_name] As [Class_name], [t0]. [St_name] From [Student] as [T0]left OUTER joins [Classes] as [T1] on [t0]. [class_id] = [T1]. [CLASS_ID]
The strongest is that it gives us a lambda expression.
Students . GroupJoin ( Classes, stu = stu. class_id, cla = cla. class_id, (stu, myjoin) = new { stu = stu, myjoin = Myjoin } ) . SelectMany ( temp0 = temp0. Myjoin.defaultifempty (), (temp0, GRP) = = new {ClassId = grp. class_id, class_name = grp. Class_name, st_name = Temp0.stu.St_Name } )
Look at the inner join again.
Inner join from Stu in Studentsjoin Cla in Classeson Stu. class_id equals CLA. Class_idselect new {Classid=cla. Class_id,class_name=cla. Class_name,st_name =stu. St_name}
Look at the SQL results, are we right?
SELECT [T1]. [CLASS_ID] As [ClassId], [T1]. [Class_name] As [Class_name], [t0]. [St_name] From [Student] as [T0]inner joins [Classes] as [T1] on [t0]. [class_id] = [T1]. [CLASS_ID]
That's right
Look at the lambda expression again.
Students . Join ( Classes, stu = stu. class_id, cla = cla. class_id, (Stu, CLA) = new { ClassId = cla. class_id, class_name = cla. Class_name, st_name = stu. St_name } )
You can learn more about this tool here.
(The above text from: http://www.cnblogs.com/li-peng/p/3441729.html)
The following is added by "Luzin":
Ps:
I was learning the entity Framework4 video when a lecturer referred to the LINQPad tool.
Http://v.youku.com/v_show/id_XMzA4MTQ0Mjk2.html
For beginners, you can quickly master and get started with LINQ by Learning LINQPad's "Samples".
LINQPad Fast Learning LINQ (with video)