Интегрированные в язык запросы (linq) в microsoft visual studio 2008
DESCRIPTION
Интегрированные в язык запросы (LINQ) в Microsoft Visual Studio 2008 . Роман Здебский Microsoft [email protected] http://blogs.msdn.com/roman. Содержание. Зачем нужен LINQ ? – проблематика и постановка задачи Основные идеи LINQ Сценарии использования - PowerPoint PPT PresentationTRANSCRIPT
1 (LINQ) Microsoft Visual Studio 2008 Microsoft
[email protected] http://blogs.msdn.com/roman 2 LINQ? LINQ LINQ .NET
3:Data != Objects4 T/SQL
Oracle SQL*Plus
USE NorthwindSELECT ProductName,UnitPrice, UnitsInStockFROM productsWHERE productID p.ProductName== "Chai"); product.UnitsInStock = 11; product.ReorderLevel = 10; product.UnitsOnOrder = 2; db.SubmitChanges();Delete var supplier = db.Suppliers.FirstOrDefault(s=>s.CompanyName == ABC"); if ((supplier != null) && (supplier.Products.Count == 0)) { db.Suppliers.Remove(supplier); db.SubmitChanges(); } NorthwindDataContext db = new NorthwindDataContext(); Supplier supplier = new Supplier{CompanyName = ABC}; db.Suppliers.Add(supplier); db.SubmitChanges();
Add4546LINQ to Objects C# VB
SQL- .NET collection ( IEnumerable)
LINQ DataBinding47LINQ XML XML XmlDocument doc = new XmlDocument();XmlElement contacts = doc.CreateElement("contacts");foreach (Customer c in customers) if (c.Country == "USA") { XmlElement e = doc.CreateElement("contact"); XmlElement name = doc.CreateElement("name"); name.InnerText = c.CompanyName; e.AppendChild(name); XmlElement phone = doc.CreateElement("phone"); phone.InnerText = c.Phone; e.AppendChild(phone); contacts.AppendChild(e); }doc.AppendChild(contacts);
Great Lakes Food (503) 555-7123
ImperativemodelDocumentcentricNo integrated queriesMemory intensive48XDocument loaded = XDocument.Load(@"C:\contacts.xml");contacts var q = from c in loaded.Descendants("contact") where (int)c.Attribute("contactId") < 4 select (string)c.Element("firstName") + + (string)c.Element("lastName");LINQ to XML XML LINQXElement contacts = new XElement("contacts", from c in customers where c.Country == "USA" select new XElement("contact", new XElement("name", c.CompanyName), new XElement("phone", c.Phone) ));Declarative modelElementcentricIntegrated queriesSmaller and faster49LINQ To XMLLanguage integrated query XML XPath / XQuery C# VB DOMElement centric, document centric 50LINQ to XML objects
5152Parallel Language Integrated Query (PLINQ) ParallelFXLINQ to ObjectsLINQ to XML LINQ to SQL SQL Server:Reference System.Concurrency.dllWrap your data source in an IParallelEnumerable with a call to the System.Linq.ParallelEnumerable.AsParallel extension method.
53Parallel Language Integrated Query (PLINQ) :pipelined processingstop-and-go processinginverted enumeration
IEnumerable leftData = ..., rightData = ...; var q = from x in leftData.AsParallel() join y in rightData on x.a == y.b select f(x, y); 54LINQ Language Integrated Query .NET C# 3.0 VB 9.0
LINQ to ObjectsSQL-like .NET
LINQ to SQL LINQ to XML, XML DOM LINQ to EntitiesLINQ to Datasets55LINQ , XML SQL XQuery C# VB , IntelliSense, refactoring APIs56Third-Party LINQ Providers LINQ to WebQueries (MSDN Web sites)LINQ to Amazon (books search)LINQ to RDF Files. LINQ to MySQL LINQ to NHibernate LINQ to LDAP LINQ to Google Desktop LINQ to SharePoint LINQ to Streams (SLinq, Streaming LINQ) LINQ to Expressions (MetaLinq) 57 paging LINQ?58 LINQ microsoft.com The LINQ Project
Anders HejlsbergChief Designer of C#Architect of LINQ project
59 T/SQL? LINQ ,
60 (LINQ) Microsoft Visual Studio 2008 Microsoft
[email protected]://blogs.msdn.com/roman 14:00 15:0061
62
63XAttribute
XNode
XComment
XContainer
XDeclaration
XDocument
XDocumentType
XElement
XName
XProcessingInstruction
XText
XNamespace
XStreamingElement