Geeks With Blogs
Saqib Ullah BootStrapper Know How
Microsoft Babies
Microsoft new baby yes I am talking about LINQ stand for Language-Integrated Query is now available as a integral part of Visual Studio Orcas. Microsoft releases the new Visual Studio with the name of Orcas and all Microsoft previous efforts (Windows Communication Foundation WCF, Windows Workflow Foundation WWF, Windows Presentation Foundation WPF, Windows CardSpace and LINQ) are integrated in this Studio. From last one and half years Anders Hejlsberg team done a tremendous job in the overcoming the gap between the data impedance. Mr. Anders team gives a native syntax to developers in the form LINQ to C# and VB.Net for accessing data from any repository. The repository could be in memory object, database (still MS SQL Server only) and XML files.
 
What is LINQ?
Still lots of folks don’t understand what LINQ is doing. Basically LINQ address the current database development model in the context of Object Oriented Programming Model. If some one wants to develop database application on .Net platform the very simple approach he uses ADO.Net. ADO.Net is serving as middle ware in application and provides complete object oriented wrapper around the database SQL. Developing application in C# and VB.Net so developer must have good knowledge of object oriented concept as well as SQL, so it means developer must be familiar with both technologies to develop an application. If here I can say SQL statements are become part of the C# and VB.Net code so it’s not mistaken in form of LINQ. According to Anders Hejlsberg the chief architect of C#.
 
             “Microsoft original motivation behind LINQ was to address the impedance mismatch between programming languages and database.”
 
LINQ has a great power of querying on any source of data, data source could be the collections of objects, database or XML files. We can easily retrieve data from any object that implements the IEnumerable<T> interface. Microsoft basically divides LINQ into three areas and that are give below.
 
  • LINQ to Object {Queries performed against the in-memory data}
  • LINQ to ADO.Net
    • LINQ to SQL (formerly DLinq) {Queries performed against the relation database only Microsoft SQL Server Supported}
    • LINQ to DataSet {Supports queries by using ADO.NET data sets and data tables}
    • LINQ to Entities {Microsoft ORM solution}
  • LINQ to XML (formerly XLinq) { Queries performed against the XML source}
 
I hope few above lines increase your concrete knowledge about Microsoft LINQ and now we write some code snippet of LINQ.
 
1. Code Snippet

int[] nums = new int[] {0,1,2};
var res = from a in nums
             where a < 3
             orderby a
             select a;
foreach(int i in res)
    Console.WriteLine(i);
Output:
0
1
2
 
 
All SQL Operates are available in LINQ to Object like Sum Operator in the following code.
 
2. Code Snippet

int[] nums = new int[] {2,4,6,2};
int result = nums.Sum();
Console.WriteLine(result);

Output:
1
2

One thing that I want to share with you guys is LINQ to Object support querying against any object that inherits from IEnumerable (all .Net collection inherits from IEnumerable interface). LINQ to Object provided main types of Operator Type that are give below.
 
 

Operator Types
Operator Name
Aggregation
  • Aggregate
  • Average
  • Count
  • LongCount,
  • Max,
  • Min,
  • Sum
Conversion
  • Cast,
  • OfType,
  • ToArray,
  • ToDictionary,
  • ToList,
  • ToLookup,
  • ToSequence
Element
  • DefaultIfEmpty,
  • ElementAt,
  • ElementAtOrDefault,
  • First,
  • FirstOrDefault,
  • Last,
  • LastOrDefault,
  • Single,
  • SingleOrDefault
Equality
  • EqualAll
Generation
  • Empty,
  • Range,
  • Repeat
Grouping
  • GroupBy
Joining
  • GroupJoin,
  • Join
Ordering
  • OrderBy,
  • ThenBy,
  • OrderByDescending,
  • ThenByDescending,
  • Reverse
Partitioning
  • Skip,
  • SkipWhile,
  •  Take,
  •  TakeWhile
Quantifiers
  • All,
  • Any,
  • Contains
Restriction
  • Where
Selection
  • Select,
  • SelectMany
Set
  • Concat,
  • Distinct,
  • Except,
  • Intersect,
  • Union
 
To the good use of above operator types I need samle patient class so here it

using System;
 
public class Patient
{
    // Fields
    private string _name;
    private int _age;
    private string _gender;
    private string _area;
    // Properties
    public string PatientName
    {
        get { return _name; }
        set { _name = value; }
    }
 
    public string Area
    {
        get { return _area; }
        set { _area = value; }
    }
    public String Gender
    {
        get { return _gender; }
        set { _gender = value; }
    }
    public int Age
    {
        get { return _age; }
        set { _age = value; }
    }
}
 
Here is my code that intiliaze patients object with following data.
 

List<Patient> patients = new List<Patient> {
           new Patient { PatientName="Ali Khan", Age=20, Gender="Male" , Area = "Gulshan"},
           new Patient { PatientName="Ahmed Siddiqui", Age=25 ,Gender="Male", Area = "NorthKarachi" },
           new Patient { PatientName="Nida Ali", Age=20, Gender="Female", Area = "NorthNazimabad"},
           new Patient { PatientName="Sana Khan", Age=18, Gender="Female", Area = "NorthNazimabad"},
           new Patient { PatientName="Shahbaz Khan", Age=19, Gender="Male", Area = "Gulshan"},
           new Patient { PatientName="Noman Altaf", Age=19, Gender="Male", Area = "Gulshan"},
           new Patient { PatientName="Uzma Shah", Age=23, Gender="Female", Area = "NorthKarachi"}};
 
Patient p = new Patient();
        p.Age =33; p.Gender = "male";
        p.PatientName = "Hammad Ali"
        p.Area = "Defence";         
        patients.Add(p);
 
I have been written a blog on the new way of initilaztion.

This code snippet fetch those records whose gender is equal to “Male”.
 

   gdView.DataSource = from pa in patients
                        where pa.Gender == "Male"
                        orderby pa.PatientName, pa.Gender, pa.Age
                        select pa;
   gdView.DataBind();
 
The following code snippet uses the selection operator type, which brings all those records whose age is more than 20 years.

 var mypatient = from pa in patients
                  where pa.Age > 20
                  orderby pa.PatientName, pa.Gender, pa.Age
                  select pa;
       
        foreach(var pp in mypatient)
        {
        Debug.WriteLine(pp.PatientName + " "+ pp.Age + " " +          pp.Gender);
        }
 The following code snippet uses the grouping operator type that group patient data on the bases area. 

var op = from pa in patients
group pa by pa.Area into g
select new {area = g.Key, count = g.Count(), allpatient = g};
 
 foreach(var g in op)
 {
    Debug.WriteLine(g.count+ "," + g.area);
    foreach(var l in g.allpatient)
     {
       Debug.WriteLine("\t"+l.PatientName);
     }
 }
This code snippet determine the count of those records, which lay in above 20 years. 

int patientCount = (from pa in patients
                    where pa.Age > 20
                    orderby pa.PatientName, pa.Gender, pa.Age
                    select pa).Count();

All the above codes are few example of LINQ to Object technique of LINQ. In my up coming post you will see both LINQ to SQL and LINQ to XML code snippets.
 
Posted on Monday, April 30, 2007 9:51 AM .Net | Back to top


Comments on this post: What is LINQ?

# re: What is LINQ?
Requesting Gravatar...
This is really nice topic to gives a hats off to LINQ
Left by Rakesh Nandrajog on Aug 24, 2007 8:44 AM

# Nice article
Requesting Gravatar...
Very Good article which gives a good starting introduction into Microsoft LINQ.

Thanks Saqib!
Left by Yohan Liyanage on Sep 08, 2007 4:02 PM

# re: What is LINQ?
Requesting Gravatar...
Nice article to get an overview about MS LINQ.

Thanks
Left by Sandip Maniar on Sep 10, 2007 1:39 AM

# re: What is LINQ?
Requesting Gravatar...
I think LINQ is a little strange
Left by Charlie on Oct 31, 2007 5:24 PM

# re: What is LINQ?
Requesting Gravatar...
I didnot know anything about LINQ.

Now on reading this article , i understand what is linq.
Thank you.
Left by ARTI on Dec 02, 2007 8:56 PM

# re: What is LINQ?
Requesting Gravatar...
PLS GIVE ME A LINK WHICH EXPLAINS CLEARLY ABOUR LINQ
Left by Gopz on Dec 12, 2007 10:07 PM

# re: What is LINQ?
Requesting Gravatar...
How in the heck does the sum() in snippet #2 output 1,2 ??
Left by Matt on Dec 18, 2007 1:53 AM

# re: What is LINQ?
Requesting Gravatar...
Reallly Nice Article.

Hope for Some Others

Thanks.

Diwakar
Left by Diwakar Gautam on Dec 19, 2007 7:19 PM

# re: What is LINQ?
Requesting Gravatar...
The above description about LINQ that deals with in-memory objects. How do we use LINQ to access databse??
Thanks and regds
Subhash
Left by subhash nayak on Dec 26, 2007 1:45 PM

# re: What is LINQ?
Requesting Gravatar...
A very good introduction to LINQ

Thanks

Roshan
Left by Roshan Perera on Dec 26, 2007 4:42 PM

# re: What is LINQ?
Requesting Gravatar...
very good article on Microsoft new baby :: LINQ,
really helping me , must be .net deveopers also
Thanks & Rgds,
************************************************************
Suyog Kale
Software Programmer
SpadeWorx Software Services
302, Sai APEX, Dutta Mandir Chowk, Viman Nagar, Pune - 411 014, India

DID : +91-204-010-0506
Mobile : +91-98600-22-945
email : suyog.kale@spadeworx.com
web : www.spadeworx.com
web : www.ormux.com
************************************************************
Left by suyog.kale on Dec 30, 2007 6:27 PM

# re: What is LINQ?
Requesting Gravatar...
very good article on Microsoft new baby :: LINQ,
really helping me , must be .net developers also
Thanks & Rgds,
************************************************************
Suyog Kale
Software Programmer
SpadeWorx Software Services
302, Sai APEX, Dutta Mandir Chowk, Viman Nagar, Pune - 411 014, India

DID : +91-204-010-0506
Mobile : +91-98600-22-945
email : suyog.kale@spadeworx.com
web : www.spadeworx.com
web : www.ormux.com
************************************************************
Left by suyog.kale on Dec 30, 2007 6:38 PM

# re: What is LINQ?
Requesting Gravatar...
its a realy ultimate topic on LINQ and thanks to the team of microsoft to provide such a nice concept
Left by Vivek uprit on Jan 01, 2008 7:24 PM

# re: What is LINQ?
Requesting Gravatar...
GOOD ONE... Its Give the Basic Idea About LINQ But .. may can give Detailed Example THat might Help Lot of New Users of .Net 2008
Left by Vijay KUmar on Jan 08, 2008 9:59 PM

# re: What is LINQ?
Requesting Gravatar...
Its really a nice stuff...
addressing the basic role of LINQ.
Lot of Thanks
Left by Hemant Ahire on Jan 11, 2008 12:05 AM

# re: What is LINQ?
Requesting Gravatar...
No one answered AM Matt question

How in the heck does the sum() in snippet #2 output 1,2 ??
Can ANy one tell.
Saqib if you can please
Left by Ahsan Riaz on Jan 18, 2008 12:38 AM

# re: What is LINQ?
Requesting Gravatar...
I'm fairly certain that the sum() in snippet #2 should output one line, 14. It's likely just a mistake made by copy-paste from the original snippet.
Left by Chad Hynes on Feb 01, 2008 10:05 AM

# re: What is LINQ?
Requesting Gravatar...
This is really nice article with good examples.

Thank you.
Left by Radheshyam Rathi on Feb 04, 2008 8:03 PM

# re: What is LINQ?
Requesting Gravatar...
Great link.........

Thanks a lot....

Asem Ibohal
Left by Asem on Feb 06, 2008 12:02 AM

# re: What is LINQ?
Requesting Gravatar...
superb intro to linq
Left by Trilok on Mar 05, 2008 11:12 PM

# re: What is LINQ?
Requesting Gravatar...
nice stuff to give a brief understanding of LINQ
Left by amitabh on Mar 21, 2008 6:50 AM

# re: What is LINQ?
Requesting Gravatar...
Very good. It gave me an overview on Linq. Thank You
Left by Ihab on Mar 26, 2008 8:44 AM

# re: What is LINQ?
Requesting Gravatar...
Thanks a lot.very nice article on Linq.
Left by Ahsan on Mar 28, 2008 10:42 PM

# re: What is LINQ?
Requesting Gravatar...
Thanks alot.

really it helped me a lot and lot
Left by Debasmit Samal on Apr 23, 2008 7:24 PM

# re: What is LINQ?
Requesting Gravatar...
its a gud article n helpd mee a lot
plz can u give an article on latest version of .net also?
Left by princy verma on Apr 27, 2008 12:06 AM

# re: What is LINQ?
Requesting Gravatar...
Absolutely brilliant
Left by Suby on Apr 28, 2008 7:10 PM

# re: What is LINQ?
Requesting Gravatar...
Superp introduction
Left by Muthukumaran on May 14, 2008 3:47 PM

# re: What is LINQ?
Requesting Gravatar...
It is really nice Article
Left by Jothibasu on May 18, 2008 10:01 PM

# re: What is LINQ?
Requesting Gravatar...
Introduction of LINQ is very nice.

Left by Mahammed Ali on May 22, 2008 9:00 PM

# re: What is LINQ?
Requesting Gravatar...
Hi Folks
this above example helps me a lot to understand about hte LINQ

i am heartly thank full to you

thanks a lot

Nushrat Ali
Sansoft IMS India
Left by Nushrat Ali on Jun 02, 2008 11:25 PM

# re: What is LINQ?
Requesting Gravatar...
great example, but the code snippets is a little strange from the basic sql syntax i know, whew!
Left by Icasper on Jun 09, 2008 5:02 PM

# re: What is LINQ?
Requesting Gravatar...
How soon this LINQ technology will boom. I like this technology I hope this could also be available in VS2005
Left by GuillAbegoon on Jun 09, 2008 8:13 PM

# re: What is LINQ?
Requesting Gravatar...
Really nice article dude. It helped me a lot to get a overview of LINQ.
Left by Kishaloy on Jun 30, 2008 8:00 PM

# re: What is LINQ?
Requesting Gravatar...
Man Hi man me sayad har developers yeisha hi kuchha khoj
rahethe jo Micosoft New Baby Ko Birth Dekar Pura Kiya,
And
Thanks saquib Bhai For Brilliant Articles
////////////////////////////////////////////////////////////////////////
Deepak sah & Sachin Sah
Software Programmer
Salleri Technology Inc.
Aadarshnagar,2nd floor Runghta Market Birgunj,Nepal

Mobile : +977-9806882802
email : deepak_niitbrj@yahoo.com/deepak@usnet.com.np
web : www.salleri.com.np
web : www.niitbrj.com.np
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Left by Deepak & Sachin on Jul 03, 2008 9:01 PM

# re: What is LINQ?
Requesting Gravatar...
Very nice article
Thanks a lot
Left by RevathiPrasannaa on Jul 11, 2008 10:55 PM

# re: What is LINQ?
Requesting Gravatar...
Hey Jothibasu.
Zangatang?
Left by Nushrat Ali on Aug 04, 2008 1:03 PM

# re: What is LINQ?
Requesting Gravatar...
This link is very useful.
Its very simple to undestand.
Now, I have got the idea about the LINQ.
Left by Pushpa Latha on Aug 19, 2008 12:15 AM

# re: What is LINQ?
Requesting Gravatar...
Thanks for sharing the information. Its really very useful to understand the basics.
Left by Kiran Kurapaty on Aug 19, 2008 1:36 AM

# re: What is LINQ?
Requesting Gravatar...
A good Article to start LINQ

Regards,
Kamalesh
Left by Kamlaesh on Sep 04, 2008 4:03 AM

# re: What is LINQ?
Requesting Gravatar...
Nice explanation.
Can u send me more details about LINQ.
That is, Its connectivity with ADO.net and XML with examples.
I wil be very thankful
Left by Priyanka Chandok on Sep 16, 2008 3:20 AM

# re: What is LINQ?
Requesting Gravatar...
Thank you for a very nice atricle regarding LINQ, it helped me to undrestand what LINQ is. The examples you provided demonstrates data populated within an array. Can you provide an example pulling data from SQLServer?
an example comparison between doing a traditional ADO VS LINQ?

Thanks again
M. Danesh
Left by Mehdi Danesh on Oct 07, 2008 1:48 AM

# re: What is LINQ?
Requesting Gravatar...
this gives me basic information of LINQ
but i wanna to
that how it will work with asp.net
Left by pramod on Oct 13, 2008 5:25 PM

# re: What is LINQ?
Requesting Gravatar...
Is the result of Snippet #2 14?
Left by cpastudent on Oct 30, 2008 5:56 PM

# re: What is LINQ?
Requesting Gravatar...
Its a nice article...LINQ seems to have great powers... we would like to know the internal processing of LINQ and perfomance effects..Thanks
Left by Madhu Agarwal on Nov 03, 2008 6:16 PM

# re: What is LINQ?
Requesting Gravatar...
Nice article to get in LINQ
Left by Pramod Pandurang Gavate on Nov 05, 2008 6:45 PM

# re: What is LINQ?
Requesting Gravatar...
very useful article.It gives good introduction to LINQ.
Left by rajeesh on Nov 18, 2008 4:51 PM

# re: What is LINQ?
Requesting Gravatar...
hi men hats off to you....
i got what i wanted from your article ...
thanks
Left by sarath on Nov 21, 2008 1:05 AM

# re: What is LINQ?
Requesting Gravatar...
Very Nice basic Article for new beginner.
Left by vijay on Dec 14, 2008 7:22 PM

# re: What is LINQ?
Requesting Gravatar...
good article...its help more
Left by jobin on Dec 15, 2008 8:09 PM

# re: What is LINQ?
Requesting Gravatar...
nice one
Left by jobin on Dec 15, 2008 8:10 PM

# re: What is LINQ?
Requesting Gravatar...
Cool explanation.
Can u send me more details about LINQ.
That is, Its connectivity with ADO.net and XML with examples.
I will be very thankful
Left by Shaheel on Dec 28, 2008 10:52 PM

# re: What is LINQ?
Requesting Gravatar...
Why on earth would you load up all your objects into a List and THEN filter/sort them? Seems like LINQ is trying to do the database's job for it, which can only lead to poor performance and bad architecture (functionality in the UI instead of the back end).
Left by skeptic on Dec 29, 2008 5:04 PM

# re: What is LINQ?
Requesting Gravatar...
Really Good man.....But you said "In my up coming post you will see both LINQ to SQL and LINQ to XML code snippets. "
we are waiting for you reply...
Left by Raju on Dec 29, 2008 11:20 PM

# re: What is LINQ?
Requesting Gravatar...
Thanks you so much..
Now I have a clear idea on LINQ.
Left by kalyan on Jan 20, 2009 7:30 PM

# re: What is LINQ?
Requesting Gravatar...
Thanks so much...
Its really great article in LINQ. This article shows the power of LINQ.

Left by Muhammad Shoaib Siddiqui on Feb 10, 2009 6:56 PM

# re: What is LINQ?
Requesting Gravatar...
I Don't Know More Information Plz Send Me Email on my
Email ID.
Left by Kiran on Feb 24, 2009 6:00 PM

# re: What is LINQ?
Requesting Gravatar...
Thanks alot for posting such a nice article about LINQ.
As of now i clearly understand what exactly LINQ and how to use it.Can u post some of examples which are related for realtime senarios.

thanks in advance
Left by suresh on Feb 25, 2009 6:05 PM

# re: What is LINQ?
Requesting Gravatar...
Very Good Writeup about LINQ... Sample programs are simple but explains us more about LINQ...

You may be interested in this video which explains more about LINQ
http://wtv.watchtechvideos.com/topic180.html


Regards,
www.WatchTechVideos.com
Left by www.WatchTechVideos.com on Feb 27, 2009 10:56 PM

# re: What is LINQ?
Requesting Gravatar...
Great Article.
Very simple and good explained.
-----------------------------------------------
Hajan Selmani, BSc
Application Developer
EduSoft, IT Engineering
Stiv Naumov 1/1-1 , Skopje, R. Macedonia
tel. +389 2 3127323 ; +389 2 3128462
fax. +389 2 3215414
hajan@edusoft.com.mk
www.edusoft.com.mk
Left by Hajan Selmani on Mar 05, 2009 1:44 AM

# re: What is LINQ?
Requesting Gravatar...
I think link would be the easiest way for me to write more difficult code unlike the old way of programming language. Hope microsoft can more documentations about this. Thank you very much.
Left by Armando J. Amor Jr. on Mar 07, 2009 2:34 PM

# re: What is LINQ?
Requesting Gravatar...
Thanks alot......
i am an indian say thanks in hindi--"bahut badiya DADA"
Left by Bhup on Mar 20, 2009 12:12 AM

# re: What is LINQ?
Requesting Gravatar...
It is good affert

Nice

Good
thanks
Naveen Mishra
Syatem Analyst
Infoedge Solutions Pvt Ltd.
naveen@infoedgesolutions.com
Left by Naveen Kumar Mishra on Mar 29, 2009 3:18 AM

# re: What is LINQ?
Requesting Gravatar...
Good Article. You explain LINQ very well. Thanks alot and keep it up...TC
Left by Zulqarnain Satti on Apr 15, 2009 6:28 PM

# re: What is LINQ?
Requesting Gravatar...



this is very good.

Thank you..

with Regards
Narsimha
Left by Narsimha on May 04, 2009 4:19 AM

# re: What is LINQ?
Requesting Gravatar...
Hi

very nice topic.
Left by sanjeeb on May 05, 2009 5:56 AM

# re: What is LINQ?
Requesting Gravatar...
What an article!!!! :) It rocks
Left by Raj on May 10, 2009 10:36 PM

# re: What is LINQ?
Requesting Gravatar...
it was very helpful to me.......... thank u a lot........
Left by nazi on May 17, 2009 7:38 PM

# re: What is LINQ?
Requesting Gravatar...
really very good article.
thanks
Left by Arvind on May 25, 2009 6:07 PM

# re: What is LINQ?
Requesting Gravatar...
Very nice article...

Thanks a lot....my dear friend.
Left by jeneesh on Jun 01, 2009 12:34 AM

# re: What is LINQ?
Requesting Gravatar...
Excellent !
I am newbie to LINQ and have path now.
Left by Sami on Jul 17, 2009 1:35 AM

# re: What is LINQ?
Requesting Gravatar...
Very nice one
Left by vijay on Jul 21, 2009 6:49 AM

# re: What is LINQ?
Requesting Gravatar...
Excellent !
Very good introduction to LINQ
Left by Yasir Akram on Aug 10, 2009 12:57 AM

# re: What is LINQ?
Requesting Gravatar...
Good
Best
Better
Left by Rajesh Kardile on Aug 13, 2009 2:05 AM

# re: What is LINQ?
Requesting Gravatar...
Very Nice article
Left by Unmesh Takalkar on Aug 19, 2009 6:43 AM

# re: What is LINQ?
Requesting Gravatar...
LINQ defines a set of query operators that can be used to query, project
and filter data in arrays, enumerable classes, XML, relational database,
and third party data sources.
Left by Rajneesh Hajela, Mumbai on Aug 29, 2009 9:21 AM

# re: What is LINQ?
Requesting Gravatar...
Very nice Article About Linq Tanx
Left by fakhrad on Aug 30, 2009 8:19 AM

# re: What is LINQ? iam madduri srinivas yadav
Requesting Gravatar...
Thanks for giving some ideas about linqs
Left by madduri srinivas yadav on Sep 02, 2009 3:40 AM

# re: What is LINQ?
Requesting Gravatar...
Nice article which gives a good starting knowledge for introduction into Microsoft LINQ.

I need more links on latest features on .Net Framework.


Thanks,
Lavanya
Left by Lavanya on Sep 23, 2009 6:58 AM

# re: What is LINQ?
Requesting Gravatar...
linq, wtf, when would I want to do this crap!
Left by PinkFloyd43 on Sep 29, 2009 10:58 AM

# re: What is LINQ?
Requesting Gravatar...
Very good article...Good work
Left by Preethi on Oct 23, 2009 11:53 AM

# re: What is LINQ?
Requesting Gravatar...
Hi,
Interesting way to look at; for the most part, I agree with you. It would be great if got more post like this. I appreciate it.
Left by Business Plan Writing on Nov 21, 2009 5:39 AM

# re: What is LINQ?
Requesting Gravatar...
nice article
Left by avdesh on Nov 25, 2009 1:46 AM

# re: What is LINQ?
Requesting Gravatar...
nice article
Left by avdesh on Nov 25, 2009 1:46 AM

# re: What is LINQ?
Requesting Gravatar...
Hi, this is a very good article for the beginners of LINQ as well as the good for the knowledge points also.

Prathesh
Left by prathsh on Dec 02, 2009 2:58 AM

# re: What is LINQ?
Requesting Gravatar...
very good article
Left by Kirit Patel on Dec 03, 2009 6:15 AM

# re: What is LINQ?
Requesting Gravatar...
Its really very nice article
Left by Rishad on Dec 10, 2009 1:06 AM

# re: What is LINQ?
Requesting Gravatar...
very nice article
Left by Miten Shah on Dec 22, 2009 8:29 AM

# re: What is LINQ?
Requesting Gravatar...
How in the heck does the sum() in snippet #2 output 1,2 ??Please Change output to 14
Left by praka on Jan 07, 2010 1:34 AM

# re: What is LINQ?
Requesting Gravatar...
Nice presentation to get a basic idea about LINQ.
Left by Santosh on Jan 13, 2010 5:57 AM

# re: What is LINQ?
Requesting Gravatar...
Hi
Thanks my friend,it's nice
Left by Ramin Habibi on Jan 20, 2010 12:18 AM

# re: What is LINQ?
Requesting Gravatar...
hai excelent explanation,its very helpful to me thanks
Left by roger on Feb 01, 2010 1:37 AM

# re: What is LINQ?
Requesting Gravatar...
vry bore
Left by reeee on Feb 15, 2010 8:50 AM

# re: What is LINQ?
Requesting Gravatar...
Very simple to understand. I was searching to get the idea about LINQ and finally this sit help to find what it is. Thanks a lot..
Left by Rahul on Mar 12, 2010 6:51 AM

# re: What is LINQ?
Requesting Gravatar...
hi thank you.but i dont know how update or insert or delete data from database with linq.can you help me? thank you
Left by aida on Apr 06, 2010 1:53 AM

# re: What is LINQ?
Requesting Gravatar...
nice article..check this out:
http://mindpower-kuchgane.blogspot.com/2010/05/mindpower-fact-hunt-linq-net-feature.html
Left by kuchgane on May 04, 2010 6:13 AM

# re: What is LINQ?
Requesting Gravatar...
Very good article
that help to reduce the time in development
Left by raj on May 05, 2010 10:19 AM

# re: What is LINQ?
Requesting Gravatar...
Really Very Nice Article for Beginner...........

Dinesh Sharma
MatrixSolution
Thank u
Left by Dinesh Sharma on May 21, 2010 7:03 AM

# re: What is LINQ?
Requesting Gravatar...
Very Nice Article for linq Beginners
Left by Elanchezian on Jun 22, 2010 2:12 AM

# re: What is LINQ?
Requesting Gravatar...
nice explanation :-)
Left by karthikeyan on Jun 29, 2010 8:49 PM

# re: What is LINQ?
Requesting Gravatar...
nice article.
Left by GaneshPpawar on Jul 14, 2010 4:27 AM

# What is LINQ?
Requesting Gravatar...
It's really nice for begineers..
Left by Brajesh Kumar on Aug 04, 2010 4:06 AM

# re: What is LINQ?
Requesting Gravatar...
GUD MATTER
Left by vijayeta on Aug 20, 2010 10:27 AM

# re: What is LINQ?
Requesting Gravatar...
perfectly defined What is LINQ?
nice article.....
tx for posting
Left by saikanth on Sep 01, 2010 12:35 PM

# re: What is LINQ?
Requesting Gravatar...
good article waiting for linq to sql
Left by nikeeta on Sep 08, 2010 3:44 AM

# re: What is LINQ?
Requesting Gravatar...
Learning made simple :)
Left by Sharmistha on Oct 15, 2010 4:48 AM

# re: What is LINQ?
Requesting Gravatar...
an informative article on LINQ
Left by debi patnaik on Nov 26, 2010 3:16 AM

# re: What is LINQ?
Requesting Gravatar...
Nice Article from linq
Left by karthik on Dec 05, 2010 12:24 AM

# re: What is LINQ?
Requesting Gravatar...
good one
Left by Ravi Nigam on Dec 09, 2010 1:37 AM

# re: What is LINQ?
Requesting Gravatar...
good article on linq to objects but linq to sql is most desirable pls post asap thanx.
Left by Mohammed.Khaleeluddin on Dec 10, 2010 6:02 AM

# re: What is LINQ?
Requesting Gravatar...
nice article for novice thanks .....
Left by shrikant on Dec 13, 2010 1:09 AM

# re: What is LINQ?
Requesting Gravatar...
It's really nice for begineers
Left by jaaydaad.com on Dec 24, 2010 1:26 AM

# re: What is LINQ?
Requesting Gravatar...
Really nice work.

Appreciated your article.

Very Helpful
Left by Shahnawaz on Jan 06, 2011 4:35 AM

# re: What is LINQ?
Requesting Gravatar...
Wonderfull starter for LINQ
Thanks a lot dude.. :)
Left by Junaid on Feb 07, 2011 2:01 AM

# re: What is LINQ?
Requesting Gravatar...
Really it,s amazing for beginners.please mail new concepts about LINQ.Thanks for ur Tutorial
Left by srinivas on Feb 23, 2011 6:06 AM

# re: What is LINQ?
Requesting Gravatar...
Very nice topic about LINQ!
Thanks very much.
I like the article.
Left by LINQ Hosting on Mar 07, 2011 6:19 AM

# re: What is LINQ?
Requesting Gravatar...
Hi this is a very good Articl for the beginnes of Linq.as will as the good for the knowlege points also chandan
Left by chandan barnwal on Apr 01, 2011 3:19 AM

# Good tutorial
Requesting Gravatar...
Thank you for letting me understand what LINQ is. It is quite technical and some terminologies are still jargon to me. This is a good start though.
Left by Student discounts on Apr 08, 2011 2:28 PM

# re: What is LINQ?
Requesting Gravatar...
Very Nice Introduction about LINQ,Thank for posting this introduction
Left by Pavan kumar konduri on Apr 24, 2011 11:33 PM

# re: What is LINQ?
Requesting Gravatar...
It's really nice for list concept.
Left by rakesh on Apr 27, 2011 11:01 PM

# re: What is LINQ?
Requesting Gravatar...
Very Nice Introduction about LINQ,Thank for posting this introduction
Left by r singh on May 19, 2011 9:50 PM

# C: What is LINQ?
Requesting Gravatar...
Microsoft Babies
Microsoft new baby yes I am talking about LINQ stand for Language-Integrated Query is now available as a integral part of Visual Studio Orcas. Microsoft releases the new Visual Studio with the name of Orcas and all Microsoft previous efforts (Windows Communication Foundation WCF, Windows Workflow Foundation WWF, Windows Presentation Foundation WPF, Windows CardSpace and LINQ) are integrated in this Studio. From last one and half years Anders Hejlsberg team done a tremendous job in the overcoming the gap between the data impedance. Mr. Anders team gives a native syntax to developers in the form LINQ to C# and VB.Net for accessing data from any repository. The repository could be in memory object, database (still MS SQL Server only) and XML files.

What is LINQ?
Still lots of folks don’t understand what LINQ is doing. Basically LINQ address the current database development model in the context of Object Oriented Programming Model. If some one wants to develop database application on .Net platform the very simple approach he uses ADO.Net. ADO.Net is serving as middle ware in application and provides complete object oriented wrapper around the database SQL. Developing application in C# and VB.Net so developer must have good knowledge of object oriented concept as well as SQL, so it means developer must be familiar with both technologies to develop an application. If here I can say SQL statements are become part of the C# and VB.Net code so it’s not mistaken in form of LINQ. According to Anders Hejlsberg the chief architect of C#.

“Microsoft original motivation behind LINQ was to address the impedance mismatch between programming languages and database.”

LINQ has a great power of querying on any source of data, data source could be the collections of objects, database or XML files. We can easily retrieve data from any object that implements the IEnumerable<T> interface. Microsoft basically divides LINQ into three areas and that are give below.


LINQ to Object {Queries performed against the in-memory data}
LINQ to ADO.Net
LINQ to SQL (formerly DLinq) {Queries performed against the relation database only Microsoft SQL Server Supported}
LINQ to DataSet {Supports queries by using ADO.NET data sets and data tables}
LINQ to Entities {Microsoft ORM solution}
LINQ to XML (formerly XLinq) { Queries performed against the XML source}


I hope few above lines increase your concrete knowledge about Microsoft LINQ and now we write some code snippet of LINQ.

1. Code Snippet
Left by V on May 19, 2011 9:54 PM

# re: What is LINQ?
Requesting Gravatar...
using System;

public class Patient
{
// Fields
private string _name;
private int _age;
private string _gender;
private string _area;
// Properties
public string PatientName
{
get { return _name; }
set { _name = value; }
}

public string Area
{
get { return _area; }
set { _area = value; }
}
public String Gender
{
get { return _gender; }
set { _gender = value; }
}
public int Age
{
get { return _age; }
set { _age = value; }
}
}

Here is my code that intiliaze patients object with following data.


List<Patient> patients = new List<Patient> {
new Patient { PatientName="Ali Khan", Age=20, Gender="Male" , Area = "Gulshan"},
new Patient { PatientName="Ahmed Siddiqui", Age=25 ,Gender="Male", Area = "NorthKarachi" },
new Patient { PatientName="Nida Ali", Age=20, Gender="Female", Area = "NorthNazimabad"},
new Patient { PatientName="Sana Khan", Age=18, Gender="Female", Area = "NorthNazimabad"},
new Patient { PatientName="Shahbaz Khan", Age=19, Gender="Male", Area = "Gulshan"},
new Patient { PatientName="Noman Altaf", Age=19, Gender="Male", Area = "Gulshan"},
new Patient { PatientName="Uzma Shah", Age=23, Gender="Female", Area = "NorthKarachi"}};

Patient p = new Patient();
p.Age =33; p.Gender = "male";
p.PatientName = "Hammad Ali";
p.Area = "Defence";
patients.Add(p);

I have been written a blog on the new way of initilaztion.

This code snippet fetch those records whose gender is equal to “Male”.

gdView.DataSource = from pa in patients
where pa.Gender == "Male"
orderby pa.PatientName, pa.Gender, pa.Age
select pa;
gdView.DataBind();

The following code snippet uses the selection operator type, which brings all those records whose age is more than 20 years.

var mypatient = from pa in patients
where pa.Age > 20
orderby pa.PatientName, pa.Gender, pa.Age
select pa;

foreach(var pp in mypatient)
{
Debug.WriteLine(pp.PatientName + " "+ pp.Age + " " + pp.Gender);
}
The following code snippet uses the grouping operator type that group patient data on the bases area.

var op = from pa in patients
group pa by pa.Area into g
select new {area = g.Key, count = g.Count(), allpatient = g};

foreach(var g in op)
{
Debug.WriteLine(g.count+ "," + g.area);
foreach(var l in g.allpatient)
{
Debug.WriteLine("\t"+l.PatientName);
}
}
This code snippet determine the count of those records, which lay in above 20 years.

int patientCount = (from pa in patients
where pa.Age > 20
orderby pa.PatientName, pa.Gender, pa.Age
select pa).Count();
Left by What is LINQ? on May 19, 2011 9:56 PM

# re: What is LINQ?
Requesting Gravatar...
Nice link
Left by Tanushree Gaonkar on May 25, 2011 9:11 PM

# Business Plan writers
Requesting Gravatar...
If you are looking for professional business plan consultants, business plan experts and business plan writers, please feel free to contact B-Plan Experts business plan consultant - your best business plan expert.
Left by Business Plan on May 30, 2011 7:43 PM

# re: What is LINQ?
Requesting Gravatar...
with above example of patient it is easy to understand. Thanks.
Left by narendra Sonone on Jun 06, 2011 6:20 AM

# # Business Plan writers 7/7/2011 12.46 PM
Requesting Gravatar...
If you are looking for professional business plan consultants, business plan experts and business plan writers, please feel free to contact B-Plan Experts business plan consultant - your best business plan expert.

Left by Business Plan Consultant on Jun 06, 2011 7:17 PM

# re: What is LINQ?
Requesting Gravatar...
it is very easy to understand. i like the article thanks
Left by mrityunjay mall on Jul 04, 2011 3:29 AM

# re: What is LINQ?
Requesting Gravatar...
thanks....this is a good artical
Left by Sandeep Kheriwal on Jul 12, 2011 6:38 AM

# re: What is LINQ?
Requesting Gravatar...
very nice and very helpfull article
thankyou
Left by punya on Jul 13, 2011 6:44 AM

# re: What is LINQ?
Requesting Gravatar...
Thanks for sharing excellent tutorial on LINQ.
Left by Imdadhusen on Jul 18, 2011 12:48 AM

# re: What is LINQ?
Requesting Gravatar...
Greate It's Really good For Beginners..
Waiting For Linq To XML Article
Left by Rahul Rajput on Jul 21, 2011 6:45 PM

# re: What is LINQ?
Requesting Gravatar...
There are certainly a lot more details to take into consideration, but thanks for sharing this post.
SharePoint looks much more professional. It comes at a cost, but offers a number of services designed for larger companies.
SharePoint Consulting
Left by SharePoint Consulting on Jul 21, 2011 6:53 PM

# re: What is LINQ?
Requesting Gravatar...
Why few people are worried about wrong out put for Sum() snippet #2. Please focus on the technology buddy!!
Left by Sachin Ambekar on Jul 24, 2011 10:40 PM

# re: What is LINQ?
Requesting Gravatar...
Nice Article on LINQ.
Left by Sundar on Jul 31, 2011 4:08 PM

# re: What is LINQ?
Requesting Gravatar...
I really dont know before what is LINQ,but now i have a clearcut idea on it.
Left by Sundar on Jul 31, 2011 4:08 PM

# re: What is LINQ?
Requesting Gravatar...
thankxxx a lot.
Left by mritunjai on Aug 08, 2011 12:21 AM

# re: What is LINQ?
Requesting Gravatar...
It's very good ,those who dnt know about the LINQ they can easily understand.
Thanks.......
Left by shilpa on Aug 19, 2011 6:02 PM

# re: What is LINQ?
Requesting Gravatar...
Great post! I?m just starting out in community management/marketing media and trying to learn how to do it well. Singapore travel
Left by Holiday Forum on Sep 09, 2011 9:06 AM

# re: What is LINQ?
Requesting Gravatar...
like this idea, thanks for sharing. 388A Sbobet Casino
Left by Agen Bola on Sep 09, 2011 9:11 AM

# re: What is LINQ?
Requesting Gravatar...
Its a very nice article
Left by sheeloo sachan on Sep 14, 2011 3:33 PM

# re: What is LINQ?
Requesting Gravatar...
nice article with linq..
Left by jaya on Sep 28, 2011 5:37 PM

# re: What is LINQ?
Requesting Gravatar...
Hi,
The output for the Example2 code snippet is shown as "1", "2"

Actual output is "14".which is the sum of 2, 4, 6, 2.

Could you please Chech that Out
Left by Soumya on Sep 29, 2011 5:16 PM

# re: What is LINQ?
Requesting Gravatar...
how can i add new object to the list??
Left by anand pal on Oct 05, 2011 9:35 PM

# re: What is LINQ?
Requesting Gravatar...
This is very interesting topic and I think it is clear Linq for every new programmer.
Left by Anuj Agnihotri on Oct 21, 2011 5:16 PM

# What is LINQ?
Requesting Gravatar...
This is very interesting topic and I think it is clear Linq for every new programmer and I want to know about Generics Plz clear generics in Simple way
Left by Anuj Agnihotri on Oct 21, 2011 5:18 PM

# re: What is LINQ?
Requesting Gravatar...
very gooooooooooooood.im from iran-abadan
Left by reza on Oct 22, 2011 7:18 PM

# re: What is LINQ?
Requesting Gravatar...
Very nice article. I really enjoyed it reading. And it also cleared lot of my doubts about LINQ in .Net. Check this link...
http://www.mindstick.com/Blog/53/LINQ%20in%20NET
Its helped me to complete my task.

Thanks Everyone!!
Left by Ajay Singh on Nov 16, 2011 10:24 PM

# re: What is LINQ?
Requesting Gravatar...
Very nice...very useful too
Left by Meena on Nov 19, 2011 3:46 AM

# re: What is LINQ?
Requesting Gravatar...
Very nice Article,
I want to know about Generics Plz clear generics in Simple way with best example.
Thanks

Left by grajkumarmsc on Nov 30, 2011 11:13 PM

# re: What is LINQ?
Requesting Gravatar...
it's helpful.

Reallly Nice Article.
Hope for Some Others
Thanks.
Left by Tapan on Dec 02, 2011 3:46 PM

# re: What is LINQ?
Requesting Gravatar...
it's very helpful.

and very simple.
if i found more query in future the i will ask u?
thanks.
Left by Tapan on Dec 02, 2011 3:48 PM

# re: What is LINQ?
Requesting Gravatar...
Nice super good
Left by siva on Dec 11, 2011 5:07 AM

# re: What is LINQ?
Requesting Gravatar...
it's very helpful.and very simple.
but how to connect database please send steps for me

Left by suman on Dec 12, 2011 6:51 PM

# re: What is LINQ?
Requesting Gravatar...
Picking to buy bridesmaid wedding dresses in colors like red and green in December, pale yellow and lavender in spring will be a good deal much less high-priced. Also choosing colours that are readily available can cost less than obtaining custom fabric with alternative of certain colours.



Left by One Shoulder Evening Dresses on Dec 18, 2011 6:23 PM

# re: What is LINQ?
Requesting Gravatar...
It's really a nice topic and the examples mentioned made my concept clear about how to use LINQ.

Thanks.
Left by Sadia Tariq on Dec 29, 2011 5:01 PM

# re: What is LINQ?
Requesting Gravatar...
Gud one...
Left by Madhu Jajula on Jan 08, 2012 9:41 PM

# re: What is LINQ?
Requesting Gravatar...
Very Well. . .

Pawan Dubey
LNT Infotech
Left by Pawankumar on Feb 08, 2012 11:38 PM

# re: What is LINQ?
Requesting Gravatar...
Really nice articles. I think it helps beginner too much
Left by Sachin Dev Tripathi on Mar 11, 2012 7:47 PM

# re: What is LINQ?
Requesting Gravatar...
Really .. nice articles. I think it helps beginner too much
Left by Sachin Dev Tripathi on Mar 11, 2012 7:47 PM

# re: What is LINQ?
Requesting Gravatar...
Thank you very much for this introduction , it gave me a very good understanding for LINQ technoogy
Left by Muhannad al Hariri on Apr 12, 2012 10:09 PM

# re: What is LINQ?
Requesting Gravatar...
Its really good and less time taking.Thanks
Left by Sonali on Apr 29, 2012 5:20 PM

# re: What is LINQ?
Requesting Gravatar...
great article, thanks
Left by amir sabri on May 05, 2012 11:53 PM

# re: What is LINQ?
Requesting Gravatar...
Nice and very good article for beginners in LINQ, Thanks
Left by dil on May 21, 2012 9:33 PM

# re: What is LINQ?
Requesting Gravatar...
Nice Article ...

Thanks,
Divya
Left by Divya on Jun 28, 2012 5:48 PM

# re: What is LINQ?
Requesting Gravatar...
good introduction linq
Left by Md Zahir Ansari on Jun 28, 2012 6:09 PM

# re: What is LINQ?
Requesting Gravatar...
THIS ARTICLE IS VERY NICE N KNOWLEDGEABLE.
Left by kumar on Jul 01, 2012 4:49 PM

# re: What is LINQ?
Requesting Gravatar...
Thanks' a lot.....!
Left by Yash on Jul 10, 2012 6:28 PM

# re: What is LINQ?
Requesting Gravatar...
Sends Gift to India helps you to send flowers, cakes, Valentine gifts across India. Send gift to all cities like Bangalore, Kolkata, Delhi, Chennai, Mumbai and many more.
Left by Gift to India on Jul 17, 2012 7:43 PM

# re: What is LINQ?
Requesting Gravatar...
Nice link to see.
Now i have a idea about the LINQ.

Thanks
Left by Ramesh on Jul 24, 2012 1:25 AM

# re: What is LINQ?
Requesting Gravatar...
Nicely explained ! Thanks
Left by Pankaj on Sep 10, 2012 11:47 PM

# re: What is LINQ?
Requesting Gravatar...
Thanks alot. I like the examples you used :)
Left by madeline on Sep 18, 2012 4:31 PM

# re: What is LINQ?
Requesting Gravatar...
it s very intresting.i want to know how we use the data from database by using linq
Left by satish on Oct 24, 2012 5:04 PM

# re: What is LINQ?
Requesting Gravatar...
Very Nice Post. Now i have idea about linq.
Left by Sudhakar on Nov 12, 2012 12:46 AM

# re: What is LINQ?
Requesting Gravatar...
Thanks a lot. Very Nice Post about Linq. Clears the confusion of LINQ to Object, LINQ to ADO.net and LINQ to XML.
Left by Omkar on Nov 19, 2012 7:05 AM

# re: What is LINQ?
Requesting Gravatar...
hey.. its nice... n easy to learn..
Left by Sudhakar on Nov 28, 2012 1:18 AM

# re: What is LINQ?
Requesting Gravatar...
Greate. give a clear picture about LINQ
Left by Abid on Dec 07, 2012 5:56 PM

# re: What is LINQ?
Requesting Gravatar...
the best site
your paper is good.
thank you very much.
my tel:09191906586
if you was GAUCHE call me.
Left by morteza on Jan 20, 2013 8:28 AM

# re: What is LINQ?
Requesting Gravatar...
Very nice link and also now i have idea about LINQ
Left by Satheeshkumar on Feb 10, 2013 11:09 PM

# re: What is LINQ?
Requesting Gravatar...
Good Article.
Could please write Query that returns the patients details with highest age.
Left by veerabhadra on Mar 28, 2013 6:16 PM

# re: What is LINQ?
Requesting Gravatar...
Good Article about LINQ,

Really its very useful to me that LINQ to Objects.
Please post he LINQ to SQL and LINQ to XML as soon as possible
Left by KRISHNACHAITANYA on Apr 22, 2013 6:11 PM

# re: What is LINQ?
Requesting Gravatar...
The article is very nice and usefull. Thanks a lot.
Left by Gokul on May 06, 2013 1:10 AM

# re: What is LINQ?
Requesting Gravatar...
Yes, It's nice article. Some one say that LINQ is 10 time faster than SQl is it ?
Left by Sheikh M G on Apr 12, 2014 2:22 AM

# re: What is LINQ?
Requesting Gravatar...
LINQ address the current database development model in thecontext of Object Oriented Programming Model. If we want to develop database applicationin .Net platform then there will be very simple approach like we will useADO.NET because it will work as a middleware to connect database, for businesslogic we should be good in C# or VB.NET so overall we should have goodknowledge in both database programming (SQL) and in Object Oriented Programmingbut here SQL statements become the part of C# and VB.NET code in the form ofLINQ. So we can write database code in C# or VB.NET.



LINQ has a great power of querying on any source of data,data source could be the collections of objects, database or XML files. We caneasily retrieve data from any object that implements the IEnumerable<T> interface. Microsoft divides LINQ into three areas.



LINQ to Object {Queries performed against the in-memory data}
LINQ to ADO.Net
LINQ to SQL (formerly DLinq) {Queries performed against the relation database only Microsoft SQL Server Supported}
LINQ to DataSet {Supports queries by using ADO.NET data sets and data tables}
LINQ to Entities {Microsoft ORM solution}
LINQ to XML (formerly XLinq) { Queries performed against the XML source}

refereed from:
http://www.mindstick.com/blog/8/What%20is%20LINQ
Left by JOTSANA on Dec 15, 2014 7:20 PM

# Salesforce Development Services
Requesting Gravatar...
Get the best solutions for salesforce development, cloud base, big data services, analytics services, SAP Hybris and digital services. For more info contact us @ <a href="http://www.mannyats.com/>Salesforce.
Left by Salesforce on Nov 17, 2017 5:22 PM

Your comment:
 (will show your gravatar)


Copyright © Saqib Ullah | Powered by: GeeksWithBlogs.net