Paul Yuknewicz Lead Program Manager Microsoft Visual Basic DEV 319.

Slides:



Advertisements
Similar presentations
The Microsoft Technical Roadshow 2007 Language Enhancements and LINQ Daniel Moth Developer & Platform Group Microsoft Ltd
Advertisements

Language Integrated Query (LINQ) Martin Parry Developer & Platform Group Microsoft Ltd
© 2009 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.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Michael Pizzo Software Architect Data Programmability Microsoft Corporation.
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
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.
Live from Redmond: WebCast Conquering XML with Visual Basic 9 Amanda Silver Lead Program Manager Visual Basic Level: Starts Easy, Finishes Advanced.
ASP.NET 3.5 New Features. 2 Agenda What's New in.NET Framework 3.5? Visual Studio 2008 Enhancements LINQ (Language Integrated Query) New ASP.NET Server.
C# 3.0 & LINQ Raimond Brookman – IT Architect
LinqToSharePoint SandBoxed Solution Shakir Majeed Khan
Building a Complete Web Application Using ASP.NET 3.5 & Visual Studio 2008 (Part 1 of 2) Jeff King Program Manager Microsoft Corporation
The Microsoft Technical Roadshow 2007 Advances for Data in VS “Orcas” Mike Taulty Developer & Platform Group Microsoft Ltd
What’s new in ASP.NET 3.5? Mike Ormond Developer & Platform Group Microsoft Ltd
NameTitle Microsoft Corporation. For businesses with Visual Basic 6.0 assets, Visual Basic 2008 is the natural, most productive choice for Windows, Web,
Multitenant Model Request/Response General Model.
Beth Massi Program Manager Visual Studio Community.
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
Session 1.
LINQ Programming in C# LINQ CSE Prof. Roger Crawfis.
Built by Developers for Developers…. © 2009 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.
Ronnie Saurenmann Principal Architect Microsoft Switzerland.
LINQ and C# 3.0 Mads Torgersen Program Manager for the C# Language Microsoft Corporation.
© 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.
ADO.NET Entity Framework Mike Taulty Developer & Platform Group Microsoft Ltd
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 …
© 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.
C#: Future Directions in Language Innovation Anders Hejlsberg TLN307 Technical Fellow Microsoft Corporation.
demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
demo Demo.
Satisfy Your Technical Curiosity C# 3.0 Raj Pai Group Program Manager Microsoft Corporation
demo QueryForeign KeyInstance /sm:body()/x:Order/x:Delivery/y:TrackingId1Z
projekt202 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Joel Pobar Language Geek Microsoft DEV320 Improve on C# % Backwards Compatible Language Integrated Query (LINQ)
© 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

Tech·Ed North America /18/2018 2:05 PM
6/26/2018 9:02 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Get Typed with TypeScript!
Upgrading Your C# Programming Skills to Be a More Effective Developer
Возможности Excel 2010, о которых следует знать
ADO.NEXT Advances in Data Access for 2008
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.
Виктор Хаджийски Катедра “Металургия на желязото и металолеене”
From Start to REST in 60 Minutes (DEV323)
Технологии доступа к данным на платформе Microsoft.NET
Шитманов Дархан Қаражанұлы Тарих пәнінің
Title of Presentation 5/24/2019 1:26 PM
Presentation transcript:

Paul Yuknewicz Lead Program Manager Microsoft Visual Basic DEV 319

“For example, I personally believe that Visual Basic did more for programming than “Object-Oriented Languages” did. Yet people laugh at Visual Basic and say it’s a bad language, and they’ve been talking about OO languages for decades. And no, Visual Basic wasn’t a great language, but I think the easy DB interfaces in Visual Basic were fundamentally more important than object orientation is, for example.”

Simplify querying data Integrate query and transform operations Unify query of object, relational, and XML data Simplify working with XML Impose structure on XML w/no schema Produce XML documents quickly Access XML members easily

Language-INtegrated Query (LINQ) Language Features (through LINQ to Objects) LINQ to Relational Data LINQ to DataSet LINQ to SQL LINQ to Entities LINQ to XML and XML Integration … and of course lots of demos!

LINQ enabled data sources LINQ To ObjectsTo Objects Objects LINQ To XMLTo XML XML LINQ-enabled ADO.NETLINQ To DatasetsTo DatasetsLINQ To SQL LINQ To EntitiesTo Entities Relational Others… Visual BasicVisual Basic C#.NET Language-Integrated Query.NET Language-Integrated Query

Dim highThreadProcs = _ From proc In Process.GetProcesses _ Where proc.Threads.Count > 10 _ Select proc.ProcessName, proc.Threads.Count Dim highThreadProcs = Process.GetProcesses(). _ Where(Function(proc As Process) proc.Threads.Count > 10). _ Select (Function(proc As Process) _ New With {.ProcessName = proc.ProcessName _.Count = proc.Threads.Count) Function _Filter1(proc As Process) As Boolean Return proc.Threads.Count > 10 End Function Function _Projection1(proc As Process) As Dim projection As New projection.ProcessName = proc.ProcessName projection.Count = proc.Threads.Count Return projection End Function

Project Select Select Filter Where, Distinct Test Any( ), All( ) Join Join On Equals Join On Equals Group Group By, Into, Group By, Into, Group Join On Equals Into Group Join On Equals Into Aggregate Count([ ]), Sum( ), Min( ), Max( ), Avg( ) Partition Skip [ While ], Take [ While ] Skip [ While ], Take [ While ] Set Union, Intersect, Except Order Order By, [ Ascending | Descending ]

Project Select Select Filter Where, Distinct Test Any( ), All( ) Join Join On Equals Join On Equals Group Group By, Into, Group By, Into, Group Join On Equals ` Into Group Join On Equals ` Into Aggregate Count([ ]), Sum( ), Min( ), Max( ), Avg( ) Partition Skip [ While ], Take [ While ] Skip [ While ], Take [ While ] Set Union, Intersect, Except Order Order By, [ Ascending | Descending ]

Dim c As New SqlConnection(…) c.Open() Dim cmd As SqlCommand( _ "SELECT c.Name, c.Phone “ & _ "FROM Customers c” & _ "WHERE c.City = "London" Dim dr As DataReader= c.Execute(cmd) While (dr.Read()) Dim name As String = r.GetString(0) Dim phone As String= r.GetString(1) Dim date As DateTime = r.GetDateTime(2) End While 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 Inherits DataContext Public Property Customers As Table(Of Customer) … End Class Dim db As New Northwind(…) Dim contacts = _ From cust in db.Customers _ Where cust.City = "London" Select cust.Name, cust.Phone For Each custInfo in contacts ColdCall(custInfo.Name, custInfo.Phone) Next Accessing data with LINQ Classes describe data Strongly typed connection Integrated query syntax Strongly typed results Tables are like collections

From before Select Fully composable Dim customers = _ From cust In db.Customers _ Select cust.Name, cust.City, cust.State, cust.ZIP Dim customers = _ From cust In db.Customers _ Select cust.Name, cust.City, cust.State, cust.ZIP _ Order By ZIP _ Select Name, City, State Operations are “built up” line-by-line and… Enables good IntelliSense Dim aCustomers = _ From cust In customers _ Where cust.Name.StartsWith(“A”) _ Select cust.Name, cust.City …across statements…across statements

Aggregation is explicit Dim customers = _ From o In Orders _ Group By o.CustomerID _ Into OrderTotal = Sum(o.Amount * o.Price) _ Select CustomerID, OrderTotal Grouping keyGrouping key Explicit aggregation Includes operators for hierarchical data Dim procs= _ From proc In System.Diagnostics.Process.GetProcesses( ) _ Aggregate thread In proc.Threads _ Into AvgThreadPriority = Average(thread.CurrentPriority) _ Select Name = proc.ProcessName, AvgThreadPriority Group already exists

Dim doc As New XmlDocument() Dim contacts As XMLElement = doc.CreateElement("contacts") For Each Dim c in Customers If (c.Country = "USA") Dim e As XMLElement = doc.CreateElement("contact") Dim name As XMLElement = doc.CreateElement("name") name.InnerText = c.CompanyName e.AppendChild(name) Dim phone As XMLElement = doc.CreateElement("phone") phone.InnerText = c.Phone e.AppendChild(phone) contacts.AppendChild(e) End If Next doc.AppendChild(contacts) <contacts> Great Lakes Food Great Lakes Food (503) (503) …</contacts> Imperative model Document- centric No integrated queries Memory- intensive

Dim contacts As New XElement("contacts", _ From cust in customers _ Where cust.Country = "USA“ _ Select New XElement("contact", _ New XElement("name", cust.CompanyName), _ New XElement("phone", cust.Phone) _ ) Declarative model Element-centric Integrated queries Smaller and faster

Dim contacts = _ <%= _ From cust In customers _ Where cust.Country = "USA" _ Select _ %> Infers Xml.Linq XElement No conceptual barrier Expression holes for computed values

Shorthand for object creation Dim emp = _ Joe 28 Engineering Dim emp = _ New XElement("employee", _ New XElement("name", "Joe"), _ New XElement("age", 28), _ New XElement("department", _ New XElement("name", "Engineering"), _ New XAttribute("id", 432)))

Element access covers all XML axes Dim employees As XElement = GetCurrentEmployeesByDept(“IT”) Dim deptID As Integer = CInt(employees.Attribute(“DeptID")) Dim emp As XElement = First(employees.Descendents(“Employee")) Dim empDOB As Date = CDate(item.Element(“DateOfBirth“).Value) Dim employees As XElement = GetCurrentEmployeesByDept(“IT”) Dim deptID As Integer = Dim emp As XElement = First(employees… ) Dim empDOB As Date = CDate(emp..Value) Attributes Descendents Elements

Language integrated query for XML Expressive power of XPath/XQuery But with Visual Basic as programming language No conceptual barrier between XML and code Leverages experience with DOM Element-centric, not document-centric Symmetry in element/attribute APIs Functional construction Text nodes are just strings Simplified XML namespace support Faster and smaller than DOM

Query expressions XML literals XML element access Nullable types Object initializers Local type inference Lambda expressions Extension methods Expression trees Anonymous types Ternary operator Coalesce operator Relaxed delegates Partial methods …and many other bug fixes and small features!

DEV318 - Strategies for Moving Your Microsoft Visual Basic 6 Investments to.NET 14/08/ :45 AM - 12:00 PM DEV319 - LINQ and XML for the Microsoft Visual Basic Developer 14/08/2007 2:20 PM - 3:35 PM DEV317 - Microsoft Visual Basic: Tips and Tricks for the Microsoft Visual Studio 2008 IDE 15/08/2007 9:00 AM - 10:15 AM

Required slide VB Team Blog Visual C# Developer Center Visual Studio Orcas Beta2 Download Page Visual Basic Developer Center & Content

© 2007 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.

LINQ to SQL Emphasis on rapid application development Direct mapping to Microsoft SQL Server family of databases Available in Orcas LINQ to Entities Focus on enterprise-grade data scenarios Flexible mapping to relational data Access to Microsoft SQL Server family and other databases through ADO.NET provider model Available in first half of 2008 CTP’s and Betas on top of Orcas releases through 2007

Implicitly-typed locals Extension methods Lambda expressions Object initializers Anonymous types Nullable types Query expressions Dim x = 5 <Extension> Sub Randomize(col As Collection) Sub Randomize(col As Collection) Function(c) c.Name New Point With {.x = 1,.y = 2 } New With { c.Name, c.Phone } From … Where … Select If emp.DOB >= Today

Variable type inferred from initializer Dim x = 5 Dim s = "Hello" Dim d = 1.0 Dim numbers = New Integer() {1, 2, 3} Dim orders = new Dictionary(Of Integer, Order)() All types are Object! Integer String Double

Namespace ArrayExtensions Module IntArrExtensions _ Function Sort(i As Integer()) As Integer() … End Function _ Sub ReverseInPlace(ByRef i As Integer()) … End Sub End Module End Namespace Extend existing types with new methods Imports ArrayExtensions Dim values() As Integer = {5, 4, 2, 1, 3} Console.WriteLine(IntegerArrExtensions.ReverseInPlace( _ IntegerArrExtensions.Sort(values)) Dim values() As Integer = GetValues() Console.WriteLine(values.Sort().ReverseInPlace()) obj.Foo(x, y)  XXX.Foo(obj, x, y)

Return _ Process.GetProcesses(). _ Where( Function(proc As Process) proc.Threads.Count > 10). _ Select( Function(proc As Process) _ New With {.Name = proc.ProcessName, _.ThreadCount = proc.Threads.Count } ) Function _Filter1(proc As Process) As Boolean Return proc.Threads.Count >10 End Function Function _Project1(proc As Process) As Return New With {.Name = proc.ProcessName, _.ThreadCount = proc.Threads.Count } End Function

Dim procs = _ From proc In Process.GetProcesses() _ Select ??? Dim procs= _ From proc In Process.GetProcesses( ) _ Select New ProcInfo With {.ProcessName = proc.ProcessName, _.Count =proc.Threads.Count } Dim procs= _ From proc In Process.GetProcesses( ) _ Select proc.ProcessName, proc.Threads.Count Class ProcInfo Public ProcessName As String Public Count As Integer End Class What goes here?

Dim procs= _ From proc In Process.GetProcesses( ) _ Select New With {.ProcessName = proc.ProcessName, _.Count = proc.Threads.Count Dim procs= _ From proc In Process.GetProcesses( ) _ Select proc.ProcessName, proc.Threads.Count Class $Anonymous1 Public ProcessName As String Public Count As Integer End Class Dim bytes = _ From Page In pages _ Select New $Anonymous1 With {.ProcessName = proc.ProcessName, _.Count = proc.Threads.Count } Type omitted from object initializer Anonymous type What is the result type?

Defer code interpretation Dim f As Predicate(Of Customer) = Function (c) c.State = "CA" Dim e As Expression(Of Predicate(Of Customer)) = Function (c) c.State = "CA" Dim e As Expression(Of Predicate(Of Customer)) = _ New Expression(Of Predicate(Of Customer))( New BinaryExpression(ExpressionType.EQ, New PropertyExpression( New ParameterExpression(0), GetType(Customer).GetProperty("State") ), New ConstantExpression("CA") ) System.Linq.Expressions.Expression(Of T) where T is a delegate type

System.Nullable(Of T) Provides nullability for any value type Structure that combines a T and a Boolean Public Structure Nullable(Of T As Structure) Private value As T Private hasValue As Boolean Public ReadOnly Property Value As T Value … End Property Public ReadOnly Property HasValue As Boolean … End Property End Structure 123 Integer 123 Nullable(Of Integer) True ??? False Non-nullNull

T? syntax Nothing unification Conversions Lifted operators Ternary operator Null coalescing Dim x As Integer? = 123 Dim y As Double?= 1.0 Dim x As Integer?= Nothing Dim y As Double?= Nothing Dim i As Integer = 123 Dim x As Integer? x = i ‘ T  T? widening Dim i = CType(x, Integer) ‘ T?  T narrowing Dim x As Integer? = GetNullableInt() Dim y As Integer?= GetNullableInt() Dim z As Integer = x + y ‘ null propagating Dim x As Integer? = GetNullableInt() Dim i As Integer = IF(x, 0) Dim x As Integer? = GetNullableInt() Dim i As Integer = IF(x, x * 2, 0)

Optionally provide implementation Partial Class DataContainer Private Partial Sub OnValueChange(value As String) End Sub Public Sub ChangeValue(newValue As String) Me.OnValueChange(newValue) Me._value = newValue End Sub End Class Partial Class DataContainer Private Sub OnValueChanged(value As String) ‘ Code to react to value changing End Sub End Class Typically found in designer generated code Only called if implementation is provided, else No-Op User code provides implementation optionally No method body for declaration

Dim custs() As Customer = SampleData.GetCustomers()custsPhoneNameID Dim q = From c In custs Where c.State = "WA“ Select c.City Dim q = custs.Where(Function(c) c.State = “WA”).Select(Function(c) c.City)Select Function(c) c.City Dim names() As String = q.ToArray()names Function(c) c.State= “WA” Where