LINQ and C# 3.0 Mads Torgersen Program Manager for the C# Language Microsoft Corporation.

Slides:



Advertisements
Similar presentations
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Advertisements

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Identity Management - Login © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Reprint Outstanding Transactions Report © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
DEV306 LINQ (Language Integrated Query)
Feature: Purchase Requisitions - Requester © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
MIX 09 4/15/ :14 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Feature: Payroll and HR Enhancements © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Live from Redmond: WebCast Conquering XML with Visual Basic 9 Amanda Silver Lead Program Manager Visual Basic Level: Starts Easy, Finishes Advanced.
C# 3.0 & LINQ Raimond Brookman – IT Architect
LinqToSharePoint SandBoxed Solution Shakir Majeed Khan
Co- location Mass Market Managed Hosting ISV Hosting.
Windows 7 Training Microsoft Confidential. Windows ® 7 Compatibility Version Checking.
Beth Massi Program Manager Visual Studio Community.
Paul Yuknewicz Lead Program Manager Microsoft Visual Basic DEV 319.
Feature: Purchase Order Prepayments II © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Feature: OLE Notes Migration Utility
Feature: Web Client Keyboard Shortcuts © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Feature: SmartList Usability Enhancements © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Session 1.
Built by Developers for Developers…. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
 Rico Mariani Architect Microsoft Corporation.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Assign an Item to Multiple Sites © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Print Remaining Documents © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Connect with life Connect with life
Лектор: Борислава Палева. Galin Iliev MCT, MCPD, MCSD.NET LINQ to XML.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
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.
Feature: Document Attachment –Replace OLE Notes © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
Feature: Suggested Item Enhancements – Sales Script and Additional Information © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows.
Feature: Customer Combiner and Modifier © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Feature: Employee Self Service Timecard Entry © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
SQL Server SQL Azure Visual Studio“Quadrant” SQL Server Modeling Services Entity Framework ADO.NET“M”/EDM Data Services …
Ian Ellison-Taylor General Manager Microsoft Corporation PC27.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
demo Instance AInstance B Read “7” Write “8”

customer.
demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
demo Demo.
demo QueryForeign KeyInstance /sm:body()/x:Order/x:Delivery/y:TrackingId1Z
Feature: Suggested Item Enhancements – Analysis and Assignment © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and.
projekt202 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
The CLR CoreCLRCoreCLR © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks.
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Ken Casada Developer Evangelist Microsoft Switzerland
Language Integrated Query Mike Taulty Developer & Platform Group Microsoft Ltd

Luke Hoban Senior Program Manager Microsoft Session Code: DTL319.
IoCompleteRequest (Irp);... p = NULL; …f(p);
Ctrl-K, X Ctrl-K, S
Возможности Excel 2010, о которых следует знать
Title of Presentation 11/22/2018 3:34 PM
Title of Presentation 12/2/2018 3:48 PM
8/04/2019 9:13 PM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Виктор Хаджийски Катедра “Металургия на желязото и металолеене”
Технологии доступа к данным на платформе Microsoft.NET
Title of Presentation 5/12/ :53 PM
Шитманов Дархан Қаражанұлы Тарих пәнінің
Title of Presentation 5/24/2019 1:26 PM
Title of Presentation 7/24/2019 8:53 PM
Presentation transcript:

LINQ and C# 3.0 Mads Torgersen Program Manager for the C# Language Microsoft Corporation

from c in db.Customers where c.City == “London” select new { c.Name, c.Address }

LINQ Architecture Objects XML Relational LINQ enabled data sources LINQ To Objects LINQ To XML LINQ enabled ADO.NET VBOthers… LINQ To Entities LINQ To SQL LINQ To Datasets.Net Language Integrated Query (LINQ) C#

C# 3.0 Language Extensions var contacts = from c in customers where c.State == "WA" select new { c.Name, c.Phone }; var contacts = customers.Where(c => c.State == "WA").Select(c => new { c.Name, c.Phone }); Extension methods Lambda expressions Query expressions Object initializers Anonymous types Local variable type inference

Language Integrated Query

Querying in Visual C# 3.0 Extension methods – call static as instance Lambda expressions – inline methods Query expressions – querying made simple Implicitly typed locals – save the typing Anonymous types – temporary results

Standard Query Operators Restrict s.Where(…) Project s.Select(…), s.SelectMany(…) Order s.OrderBy(…).ThenBy(…) … Group s.GroupBy(…) Quantify s.Any(…), s.All(…) Partition s.TakeFirst(…), s.SkipFirst(…) Set s.Distinct(), s.Union(…), s.Intersect(…), s.Except(…) Singleton s.Element(…), s.ElementAt(…) Aggregate s.Count(), s.Sum(), s.Min(), s.Max(), s.Average(), s.Aggregate() Convert s.ToArray(), s.ToList() Cast s.OfType (), s.Cast s.OfType (), s.Cast

DLinq for Relational Data SqlConnection c = new SqlConnection(…); c.Open(); SqlCommand cmd = new c.Name, c.Name, c.Phone FROM Customers c FROM Customers c WHERE c.City WHERE c.City = "London"; DataReader dr = c.Execute(cmd); while (dr.Read()) { string name = r.GetString(0); string name = r.GetString(0); string phone = r.GetString(1); string phone = r.GetString(1); DateTime date = r.GetDateTime(2); DateTime date = r.GetDateTime(2);}r.Close(); Accessing data today Queries in quotes Loosely bound arguments Loosely typed result sets No compile time checks

public class Customer { … } public class Northwind: DataContext { public Table Customers; public Table Customers; …} Northwind db = new Northwind(…); var contacts = from c in db.Customers from c in db.Customers where c.City == "London" where c.City == "London" select new { c.Name, c.Phone }; select new { c.Name, c.Phone }; DLinq for Relational Data Accessing data with DLinq Classes describe data Strongly typed connection Integrated query syntax Strongly typed results Tables are like collections

XLinq for XML Data XmlDocument doc = new XmlDocument(); XmlElement contacts = doc.CreateElement("contacts"); foreach (Customer c in customers) if (c.Country == "USA") { if (c.Country == "USA") { XmlElement e = doc.CreateElement("contact"); XmlElement e = doc.CreateElement("contact"); XmlElement name = doc.CreateElement("name"); XmlElement name = doc.CreateElement("name"); name.InnerText = c.CompanyName; name.InnerText = c.CompanyName; e.AppendChild(name); e.AppendChild(name); XmlElement phone = doc.CreateElement("phone"); XmlElement phone = doc.CreateElement("phone"); phone.InnerText = c.Phone; phone.InnerText = c.Phone; e.AppendChild(phone); e.AppendChild(phone); contacts.AppendChild(e); contacts.AppendChild(e); }doc.AppendChild(contacts); Programming XML today <contacts> Great Lakes Food Great Lakes Food (503) (503) …</contacts> Imperative model Document centric No integrated queries Memory intensive

XLinq for XML Data XElement contacts = new XElement("contacts", from c in customers from c in customers where c.Country == "USA" where c.Country == "USA" select new XElement("contact", select new XElement("contact", new XElement("name", c.CompanyName), new XElement("name", c.CompanyName), new XElement("phone", c.Phone) new XElement("phone", c.Phone) )); Programming XML with XLinq Declarative model Element centric Integrated queries Smaller and faster

LINQ Extensibility New data sources Implement the LINQ pattern New languages Unified querying experience Expression tree generation Unified call syntax Query syntax

Try it!

© 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.