Professional Documents
Culture Documents
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.
c
³
Î
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
A
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.
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.