Re-descubriendo LINQ Jose Fco Bonnin Payvision Blog: http://www.josefcobonnin.com
Agenda
Historia
LINQ Basics
LINQ to XML
LINQ to SQL
LINQ Overview C# 3.0 VB 9.0 Otros… LINQ to SQL LINQ to XML LINQ to DataSets .NET Language Integrated Query LINQ to Objects LINQ to Entities LINQ to Whatever Objetos Datos relacionales <book> <title/> <author/> <year/> <price/> </book> XML
Demo
LINQ
Historia
OR/M
Finales 2000 - Cheops
2001 PDC – Presentación ObjectSpaces
Evolución Lenguaje
2001 BillG Thinkweek – XML Types for C#
2002 XML Conference - X#
2002 Microsoft Research – Polyphonic C#
2003 XML Conference - Xen
2004 Microsoft Research – C ω
2005 PDC - Presentación oficial de LINQ
My First Query
int[] numbers = { 5, 10, 8, 3, 6, 12 };
IEnumerable<int> myFirstQuery = Enumerable.Where(numbers, num => num > 6);
myFirstQuery =
Enumerable.OrderBy(myFirstQuery, n => n);
foreach (int i in myFirstQuery)
{
Console.WriteLine(i);
}
Standard Query Operators I Agrupados por tipo de Operación
Sorting
OrderBy
ThenBy
OrderByDescending
…
Aggregation
Aggregate
Average
Count
LongCount
…
Grouping
GroupBy
ToLookUp
Projection
Select
SelectMany
…
Standard Query Operators II Agrupados por tipo de Ejecución
Immediate
Aggregate
Any
Average
First
…
Deferred - Streaming
Cast
Distinct
Select
Where
…
Deferred – Non Streaming
GroupBy
Join
OrderBy
…
Demo
Immediate and Deferred Execution
Query Expressions Syntax I
from-clause:
from [Type] identifier in expression [join clauses]
i.e from num in new int[] {1, 2, 3, 4}
join clause:
join [Type] identifier in expression on expression equals expression
Query Expressions Syntax II
Query Expression
var a = from p in people
where p.Age > 15
orderby p.Name, p.Age descending
select new { p.Name, p.Surname};
Implicitly Typed Variables Extension Methods Lambda Expression Object Initializer Anonymous Type var a = people.Where(p => p.Age > 15) .OrderBy (p => p.Name) .ThenByDescending(p => p.Age) .Select(p => new p.Name, p.Surname);
0 comments
Post a comment