About Language Integrated Query
Why we are using LINQ?
LINQ means Language Integrated Query.It is data access programming in .Net.LINQ is used to retriving the data from data bases like LINQ to XML, LINQ to SqlServer.
Namespace is : using System.Linq;
This LINQ has different types of components
Linq to Objects : It works with in memory data, that impliments IEnumerable interface
Namespace is : using System.Collections.Generic;
Example for Generate odd numbers:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
IEnumerable<int> oddNums
= ((ParallelQuery<int>)ParallelEnumerable.Range(20, 2000))
.Where(x => x % 2 != 0)
.Select(i => i);
{
class Program
{
static void Main(string[] args)
{
IEnumerable<int> oddNums
= ((ParallelQuery<int>)ParallelEnumerable.Range(20, 2000))
.Where(x => x % 2 != 0)
.Select(i => i);
foreach (int n in oddNums) { Console.WriteLine(n); }
Console.ReadLine();
}
}
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment