際際滷

際際滷Share a Scribd company logo
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);
Demo Query Expressions
 PRE LINQ to XML  W3C DOM XML XmlDocument xmlDoc = new XmlDocument(); XmlElement freaks = xmlDoc.CreateElement(&quot;Freaks&quot;); xmlDoc.AppendChild(freaks); XmlElement freak = xmlDoc.CreateElement(&quot;Freak&quot;); XmlAttribute freakType = xmlDoc.CreateAttribute(&quot;Speciality&quot;); freakType.InnerText = TFS&quot;; freak.Attributes.Append(freakType); XmlElement name = xmlDoc.CreateElement(&quot;Name&quot;); name.InnerText = &quot;Luis&quot;; freak.AppendChild(name); XmlElement surname = xmlDoc.CreateElement(&quot;Surname&quot;); surname.InnerText = &quot;Fraile&quot;; freak.AppendChild(surname); <Freaks> <Freak Specialty=&quot;TFS&quot;> <Name>Luis</Name> <Surname>Fraile</Surname> </Freak> </Freaks>
 PRE LINQ to XML  XML Lite string xml =   <Freaks> <Freak Specialty=\&quot;{0}\&quot;><Name>{1}</Name><Surname>{2}</Surname></Freak> </Freaks>; string formattedXml = string.Format(xml,  &quot;TFS&quot;, &quot;Luis&quot;, &quot;Fraile&quot;);
LINQ to XML
Demo LINQ to XML
Expression Trees Expression<Func<int,int,int>> exp = (a,b) => a + b ParameterExpression left = Expression.Parameter(typeof(int), &quot;a&quot;); ParameterExpression right= Expression.Parameter(typeof(int), &quot;b&quot;); BinaryExpression body = Expression.Add(left, right); Expression expression = Expression.Lambda(body, left, right); Add a b Left Right Body
Demo LINQ to SQL != Transact/SQL
LINQ to SQL 多S坦lo para RAD? Service Oriented Architecture, 多Se puede o no? LINQ to SQL o Entity Framework
Demo LINQ to SQL
Fin this.Dispose();
Referencias C# 3.o Specification http://msdn.microsoft.com/en-us/library/ms364047(VS.80).aspx The LINQ Project: http://msdn.microsoft.com/en-us/netframework/aa904594.aspx   Standard Query Operators http://download.microsoft.com/download/5/8/6/5868081c-68aa-40de-9a45-a3803d8134b8/Standard_Query_Operators.doc 101 Linq Samples http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx Jose Blog:  http://www.josefcobonnin.com

More Related Content

Viewers also liked (7)

PDF
Fisica dei Raggi Cosmici - Esperimento Auger - Presentazione Tesi Maglio
silviom
PPT
Roomshouse
crisholm
PPT
A1 U2 Wherecanyoubuy
crisholm
PPT
International agreements and independent advisory groups
rightsandclimate
PPS
The Woman
sahargahan
PDF
Talking psychiatry...Functional neuroimaging of schizophrenia
Professor Yasser Metwally
PDF
Research section...The role of MR imaging in the management of parkinson disease
Professor Yasser Metwally
Fisica dei Raggi Cosmici - Esperimento Auger - Presentazione Tesi Maglio
silviom
Roomshouse
crisholm
A1 U2 Wherecanyoubuy
crisholm
International agreements and independent advisory groups
rightsandclimate
The Woman
sahargahan
Talking psychiatry...Functional neuroimaging of schizophrenia
Professor Yasser Metwally
Research section...The role of MR imaging in the management of parkinson disease
Professor Yasser Metwally

Similar to Re Descubriendo A Linq (20)

PPTX
Querying the Web of Data
Rinke Hoekstra
PPT
Visual Studio .NET2010
Satish Verma
PDF
Solving performance issues in Django ORM
Sian Lerk Lau
PPT
Accessing loosely structured data from F# and C#
Tomas Petricek
PDF
Constance et qualit辿 du code dans une 辿quipe - R辿mi Pr辿vost
Web Qu辿bec
PPT
PostThis
testingphase
ODP
Soap Toolkit Dcphp
Michael Tutty
PDF
Native Phone Development 101
Sasmito Adibowo
PPT
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
CHOOSE
PDF
Python tools for testing web services over HTTP
Mykhailo Kolesnyk
PPTX
亳仄亠仆亠仆亳亠 仗舒亠仆舒 Page Object 亟仍 舒于仂仄舒亳亰舒亳亳 于亠弍 亠于亳仂于 - 仆仂于亶 于亰亞仍磲
COMAQA.BY
PPT
LINQ
coolajju143
PPTX
What's new in c# 10
Moaid Hathot
PPTX
What's new in c# 10
Moaid Hathot
PPTX
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
Thomas Cont辿
PPTX
F# for functional enthusiasts
Jack Fox
PDF
APIdays Paris 2019 - Adopting Service Mesh by Marco Palladino , Kong
apidays
PDF
improving solrs update chain - Jan hoydahl
lucenerevolution
PDF
Improving the Solr Update Chain
Cominvent AS
PPTX
Exploring SharePoint with F#
Talbott Crowell
Querying the Web of Data
Rinke Hoekstra
Visual Studio .NET2010
Satish Verma
Solving performance issues in Django ORM
Sian Lerk Lau
Accessing loosely structured data from F# and C#
Tomas Petricek
Constance et qualit辿 du code dans une 辿quipe - R辿mi Pr辿vost
Web Qu辿bec
PostThis
testingphase
Soap Toolkit Dcphp
Michael Tutty
Native Phone Development 101
Sasmito Adibowo
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
CHOOSE
Python tools for testing web services over HTTP
Mykhailo Kolesnyk
亳仄亠仆亠仆亳亠 仗舒亠仆舒 Page Object 亟仍 舒于仂仄舒亳亰舒亳亳 于亠弍 亠于亳仂于 - 仆仂于亶 于亰亞仍磲
COMAQA.BY
What's new in c# 10
Moaid Hathot
What's new in c# 10
Moaid Hathot
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
Thomas Cont辿
F# for functional enthusiasts
Jack Fox
APIdays Paris 2019 - Adopting Service Mesh by Marco Palladino , Kong
apidays
improving solrs update chain - Jan hoydahl
lucenerevolution
Improving the Solr Update Chain
Cominvent AS
Exploring SharePoint with F#
Talbott Crowell
Ad

Recently uploaded (20)

PDF
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
PDF
Kubernetes - Architecture & Components.pdf
geethak285
PPTX
Enabling the Digital Artisan keynote at ICOCI 2025
Alan Dix
PDF
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
PPTX
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
PDF
Open Source Milvus Vector Database v 2.6
Zilliz
PDF
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
PDF
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
PDF
Database Benchmarking for Performance Masterclass: Session 1 - Benchmarking F...
ScyllaDB
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
PDF
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
PDF
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
PDF
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
PDF
Unlocking FME Flows Potential: Architecture Design for Modern Enterprises
Safe Software
PPTX
UserCon Belgium: Honey, VMware increased my bill
stijn40
PDF
Python Conference Singapore - 19 Jun 2025
ninefyi
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
Kubernetes - Architecture & Components.pdf
geethak285
Enabling the Digital Artisan keynote at ICOCI 2025
Alan Dix
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
Open Source Milvus Vector Database v 2.6
Zilliz
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
The Future of Product Management in AI ERA.pdf
Alyona Owens
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
Database Benchmarking for Performance Masterclass: Session 1 - Benchmarking F...
ScyllaDB
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
Unlocking FME Flows Potential: Architecture Design for Modern Enterprises
Safe Software
UserCon Belgium: Honey, VMware increased my bill
stijn40
Python Conference Singapore - 19 Jun 2025
ninefyi
Ad

Re Descubriendo A Linq

  • 1. Re-descubriendo LINQ Jose Fco Bonnin Payvision Blog: http://www.josefcobonnin.com
  • 2. Agenda Historia LINQ Basics LINQ to XML LINQ to SQL
  • 3. 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
  • 5. 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
  • 6. 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); }
  • 7. 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
  • 8. 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
  • 9. Demo Immediate and Deferred Execution
  • 10. 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
  • 12. 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);
  • 14. PRE LINQ to XML W3C DOM XML XmlDocument xmlDoc = new XmlDocument(); XmlElement freaks = xmlDoc.CreateElement(&quot;Freaks&quot;); xmlDoc.AppendChild(freaks); XmlElement freak = xmlDoc.CreateElement(&quot;Freak&quot;); XmlAttribute freakType = xmlDoc.CreateAttribute(&quot;Speciality&quot;); freakType.InnerText = TFS&quot;; freak.Attributes.Append(freakType); XmlElement name = xmlDoc.CreateElement(&quot;Name&quot;); name.InnerText = &quot;Luis&quot;; freak.AppendChild(name); XmlElement surname = xmlDoc.CreateElement(&quot;Surname&quot;); surname.InnerText = &quot;Fraile&quot;; freak.AppendChild(surname); <Freaks> <Freak Specialty=&quot;TFS&quot;> <Name>Luis</Name> <Surname>Fraile</Surname> </Freak> </Freaks>
  • 15. PRE LINQ to XML XML Lite string xml = <Freaks> <Freak Specialty=\&quot;{0}\&quot;><Name>{1}</Name><Surname>{2}</Surname></Freak> </Freaks>; string formattedXml = string.Format(xml, &quot;TFS&quot;, &quot;Luis&quot;, &quot;Fraile&quot;);
  • 18. Expression Trees Expression<Func<int,int,int>> exp = (a,b) => a + b ParameterExpression left = Expression.Parameter(typeof(int), &quot;a&quot;); ParameterExpression right= Expression.Parameter(typeof(int), &quot;b&quot;); BinaryExpression body = Expression.Add(left, right); Expression expression = Expression.Lambda(body, left, right); Add a b Left Right Body
  • 19. Demo LINQ to SQL != Transact/SQL
  • 20. LINQ to SQL 多S坦lo para RAD? Service Oriented Architecture, 多Se puede o no? LINQ to SQL o Entity Framework
  • 23. Referencias C# 3.o Specification http://msdn.microsoft.com/en-us/library/ms364047(VS.80).aspx The LINQ Project: http://msdn.microsoft.com/en-us/netframework/aa904594.aspx Standard Query Operators http://download.microsoft.com/download/5/8/6/5868081c-68aa-40de-9a45-a3803d8134b8/Standard_Query_Operators.doc 101 Linq Samples http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx Jose Blog: http://www.josefcobonnin.com