Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2013

Slides:



Advertisements
Similar presentations
Developer Knowledge Sharing Eric Sun Dec, What programming language did you learn in school and since then? Now, its time to refresh …
Advertisements

The Microsoft Technical Roadshow 2007 Language Enhancements and LINQ Daniel Moth Developer & Platform Group Microsoft Ltd
LINQ to objects. Datenmodell Zugriffsklasse Einfache Abfrage IEnumerable booksList = SampleDataAccess.DBooks.Select(b => b); Select(...) Book => object.
LINQ (Language Integrated Query)
Deep Dive into LINQ Eran Sharabi.NET Development Team Leader JohnBryce Training
Extension Methods, Anonymous Types LINQ Query Keywords, Lambda Expressions Svetlin Nakov Telerik Corporation
.NET 3.5 – Mysteries. NetFx Evolution NetFx 1.0 C# 1.0, VB 7.0, VS.NET NetFx 1.1 C# 1.1, VB 7.1, VS 2003 NetFx 2.0 C# 2.0, VB 8.0, VS 2005 NetFx 3.0 C#
C# and LINQ Yuan Yu Microsoft Research Silicon Valley.
DryadLINQ A System for General-Purpose Distributed Data-Parallel Computing Yuan Yu, Michael Isard, Dennis Fetterly, Mihai Budiu, Úlfar Erlingsson, Pradeep.
C# 3.0 & LINQ Raimond Brookman – IT Architect
Damien Guard (BSc, MBCS) Guernsey Software Developer Forum Language Integrated Query:
C# 3.0 Tom Roeder CS fa. Version 3 From PDC 2005 preview compiler available LINQ: language-integrated query High level points: adds native query.
2.3 Cool features in C# academy.zariba.com 1. Lecture Content 1.Extension Methods 2.Anonymous Types 3.Delegates 4.Action and Func 5.Events 6.Lambda Expressions.
A tour of new features introducing LINQ. Agenda of LINQ Presentation We have features for every step of the way LINQ Fundamentals Anonymous Functions/Lambda.
XML files (with LINQ). Introduction to LINQ ( Language Integrated Query ) C#’s new LINQ capabilities allow you to write query expressions that retrieve.
LINQ Programming in C# LINQ CSE Prof. Roger Crawfis.
 Introduction  What is LINQ  Syntax  How to Query  Example Program.
Slides from Gang Luo, Xuting Zhao and Damien Guard
Reflection IT LINQ & Entity Framework Fons Sonnemans (Trainer)
LINQ, An IntroLINQ, An Intro Florin−Tudor Cristea, Microsoft Student Partner.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming I 11 th Lecture Pavel Ježek
Getting familiar with LINQ to Objects Florin−Tudor Cristea, Microsoft Student Partner.
LINQ TO XML Mike Taulty Developer & Platform Group Microsoft UK
Advanced C#, part IV Niels Hallenberg IT University of Copenhagen (With thanks to Peter Sestoft and Kasper Østerbye) BAAAP – Spring 2009.
Introduction to LINQ Lecture # 19 August Introduction How do you interrogate/manipulate data? What if you could do the work in a type-safe," string-free.
LINQ and C# 3.0 Mads Torgersen Program Manager for the C# Language Microsoft Corporation.
LINQ: It’s Not Your Father’s Data Access Denny Boynton Anheuser-Busch Companies.
The.NET Language Integrated Query Project Anders Hejlsberg TLN306 Technical Fellow Microsoft Corporation.
 Language Integrated Query  Make query a part of the language  Component of.NET Framework 3.5  Shipped with Visual Studio 2008.
Applied Linq Putting Linq to work Introducing… Class-A Kennisprovider Microsoft development Training Coaching Alex Thissen Trainer/coach.
Object Oriented Programming Generic Collections and LINQ Dr. Mike Spann
LINQ & PLINQ (Parallel) Language Integrated Query.
CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections UTPA – Fall 2011.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Linq Overview Vincent GERMAIN. Evolution - Rappel Langage  C# 2.0  C# 3.0 (Local type inference, Lambda expression, Method extension,Anonymous type)
Designing Streamable XPath Expressions Roger L. Costello January 5,
Damien Guard (BSc, MBCS) Guernsey Software Developer Forum Language Integrated Query:
Joel Pobar Language Geek Microsoft DEV320 Improve on C# % Backwards Compatible Language Integrated Query (LINQ)
IAP C# 2011 Lecture 2: Delegates, Lambdas, LINQ Geza Kovacs.
Language Integrated Query Mike Taulty Developer & Platform Group Microsoft Ltd
LINQ and Lambda Expressions Telerik Software Academy LINQ Overview.
XML & JSON. Background XML and JSON are to standard, textual data formats for representing arbitrary data – XML stands for “eXtensible Markup Language”
Introduction to.NET Florin Olariu “Alexandru Ioan Cuza”, University of Iai Department of Computer Science.
Functional Programming
Part 1: Overview of LINQ Intro to LINQ Presenter: PhuongNQK.
Introduction to Entity Framework
Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2016
Parsing XML XDocument and LINQ
LINQ for SQL SQL Saturday May 2009 David Fekke.
Querying and Transforming XML Data
Intro to LINQ Part 2 – Concepts and LINQ to Objects
Database Systems: Design, Implementation, and Management Tenth Edition
Language Integrated Query: (LINQ) An introduction
Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2005
LiNQ SQL Saturday David Fekke.
Advanced .NET Programming I 6th Lecture
.NET and .NET Core 9. Towards Higher Order Pan Wuming 2017.
Language Integrated Query (LINQ)
Chapter 4 Summary Query.
Query Functions.
Database Systems: Design, Implementation, and Management Tenth Edition
INFO 344 Web Tools And Development
Технологии доступа к данным на платформе Microsoft.NET
Set Operations Union Intersect Minus.
04 | Data Acess Technologies
LINQ - 2 Ravi Kumar C++/C# Team.
LINQ to SQL Part 3.
Advanced .NET Programming I 7th Lecture
Advanced .NET Programming I 6th Lecture
CS4540 Special Topics in Web Development LINQ to Objects
Presentation transcript:

Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2013 LINQ

References Pro C# 5.0 and the .Net 4.5 Framework, Sixth Edition, Andrew Troelsen C# in a Nutshell, 5th Edition, Albahari & Albahari Programming C# 5.0, Ian Griffiths http://msdn.microsoft.com/en-us/library/vstudio/bb397926.aspx http://en.wikipedia.org/wiki/Language_Integrated_Query http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b http://msdn.microsoft.com/en-us/library/system.xml.linq.aspx

Language INtegrated Query (LINQ) LINQ is an extension to C#, VB, and F# and has been ported to other languages as well. The extension is based on: LINQ Providers Query Operators Extension Methods Language Features Anonymous types using var keyword Lambda expressions delegates Expression Trees SQL Provider

LINQ Providers A LINQ provider publishes: library of Query operators which are implemented as extension methods Each kind of data requires its own implementation The .Net Framework has several LINQ providers and facilities: LINQ to Objects Works with IEnumerable<T> collections LINQ to SQL Works with IQueryable<T> data LINQ to XML is not an LINQ provider It is an API for creating and parsing XML documents Works with XDocument class Others: LINQ to Entities, WCF Data Services

Source<TResult> Query Operations Source IEnumerable<T> IQueryable<T> Source<T> Input collection LINQ Query Query expression Source<TResult> Query result

LINQ Queries – Extension Syntax Here is a typical query using extension method syntax: string[] cars = { "Boxter", "Mini Cooper", "Mustang", "Camaro", "Miata", "Z4" }; IEnumerable<string> query = cars .Where(n => n.StartsWith("M")) .OrderBy(n => n) .Select(n => n);

LINQ Queries – Query Syntax Here’s the same query using Query Syntax: var query = from n in cars where n.StartsWith("M") orderby n select n; Note the difference in capitalization and use of . notation

Query Operators Restriction: Where Projection: Select, SelectMany Partitioning: Take, Skip, TakeWhile, SkipWhile Ordering: OrderBy, OrderByDescending, ThenBy, ThenByDescending, Reverse Grouping: Groupby Set: Distinct, Union, Intersect, Except Conversion: ToArray, ToList, ToDictionary, OfType Element: First, FirstOrDefault, ElementAt Generation: Range, Repeat, Quantifiers: Any, All Aggregate: Count, Sum, Min, Max, Average, Aggregate Miscel: Concat, EqualAll Join: Cross Join, Group Join, Cross Join with Group Join, Left Outer Join Execution: Deferred Execution, immediate Execution, Query Reuse

LINQ to XML LINQ to XML is not based on a LINQ Provider of extension methods. LINQ to XML uses the XDocument class that builds and interrogates an XML parse tree. Many of its methods return IEnumerable<T> objects That supports LINQ to Objects queries The most important classes are: XDocument XElement XAttribute

LINQ to XML Class Diagram

XElement and XDocument We can build an XElement instance from an XML string: XElement elem = XElement.Parse(xmlString); We can build an XDocument instance from a file containing XML: XDocument doc = XDocument.Load(@”..\aFile.xml”); You can serialize an Xdocument to a File, Stream, TextWriter, or XmlWriter: doc.save(“../anXmlFile.xml”);

Query Functions XElement.Elements() returns child XElements XElement.Elements(“name”) returns child XElements with tag “name” XElement.Decendents() returns decendent Xelements XElement.DecendentNodes() returns decendent XNodes XNode.Parent returns parent Xelement XNode.Document returns the XDocument element XNode.Ancestors() returns XElement ancestors