linq-in-c# |
It represents Language
Integrated Query. It is a query language design by Microsoft using which we can
write queries on a different verity of data sources to retrieve data form data
source , like data from Array and collections.
Basically it is derived from the
SQL where SQL used in RDBMS and LINQ is use in programming language like
c#.When we going to use LINQ in programming first of all we should import the
system.Linq from library.
LINQ program example
Write a program to display the numbers greater than 40 from the array
using LINQ statement.
using Systme;
using System.Linq ;
Staic void Main()
{
int[] arr
= { 23, 34, 43,41, 54,
15, 4, 0, 66, 72, 91, 45, 17,86};
var brr = from i in arr where i>40 orderby i select i;
foreach (int a in brr)
Console.Write({“0}\t”,a);
Conosole.ReadLine();
}
Difference between SQL and LINQ
SQL |
LINQ |
||||
Ø
SQL is a Structure Query Language use in RDBMS
(Relational Data Base Management System) mainly in Sql Workbench. Ø
SQL is used in Relational Data Base to
retrieve and Manuplication of data from Tables or Relations. Ø
The syntax of SQL start from ‘Select
‘clause and end with clauses like (where, group by, having and
orderby). Ø
Syntax Select [<columns>] From [<Table>] [<Clauses>] Note : Clauses contain Where,
Groupby, Having and Orderby . clauses are optional and it always in the above sequence. |
Ø
LINQ is a Language Integrated Query use by
programmer in programming language, like in c#. Ø
LINQ is used in programming to retrieve data
form Array and Collection. Ø
The syntax starts with ‘From’
clause and end with ‘Select’ clause. Ø
Syntax from [<alias>]
in <collection | array> [<Clauses>] Select[<alias>] here all the place of
columns name we going to use alias. Alias in nothing it just a name like ‘I’,
‘a’ whatever you want names it. |
||||
Example difference |
Example difference |
||||
Suppose we have a table ‘Num’ contain only one column ‘col1’ and it
contain the following data 23, 34, 43,41, 54, 15, 4, 0, 66, 72, 91, 45, 17,86 |
Suppose we have an array ‘arr’ contain the following data same as in table 23, 34, 43,41, 54,
15, 4, 0, 66, 72, 91, 45, 17,86 |
||||
|
|
0 comments:
Post a Comment
Please do not enter any spam link in the comment box