joel pobar language geek microsoft dev320 improve on c#2.0 100% backwards compatible language...

17

Upload: lorena-jacobs

Post on 18-Jan-2018

225 views

Category:

Documents


0 download

DESCRIPTION

Improve on C# % Backwards Compatible Language Integrated Query (LINQ)

TRANSCRIPT

Page 1: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)
Page 2: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

Microsoft Visual C# Under the Covers: In-Depth C# 3.0Joel PobarLanguage GeekMicrosoft

DEV320

Page 3: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

C# 3.0 Design Themes

Improve on C#2.0

100% Backwards Compatible

Language Integrated Query (LINQ)

Page 4: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

C# 3.0 Features

demo

Page 5: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

Data != Objects

Page 6: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

The LINQ ProjectC# 3.0 VB 9.0 Others

.NET Language Integrated Query

LINQ toObjects

LINQ toDataSet

sLINQ to

SQLLINQ toEntities

LINQ toXML

Objects

<book> <title/> <author/> <year/> <price/></book>

XML

Relational

Page 7: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

Building LINQ

demo

Page 8: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

Query ExpressionsProject Select <expr>, Return <expr>Filter Where <expr>, DistinctTest Any(<expr>), All(<expr>)Join <expr> Join <expr> On <expr> = <expr>Group Group By <expr>, <expr> Aggregate <expr>,

<expr>Group Join <decl> On <expr> = <expr> Aggregate <expr>

Aggregate

Count(<expr>), Sum(<expr>), Min(<expr>), Max(<expr>), Avg(<expr>), Group(<expr>)…

Partition Skip [ While ] <expr>, Take [ While ] <expr>Set Union, Intersect, ExceptOrder Order By <expr>, <expr>

Page 9: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

C# 3.0 – New FeaturesLocal Variable Type InferenceObject Initializers

Collection InitializersAnonymous Types

Auto-Implemented PropertiesExtension MethodsLambdasQuery ExpressionsExpression TreesPartial MethodsImplicitly-Typed Arrays

Page 10: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

Summary

Motivation

Language Integrated Query

C# 3.0 New Language Features

Page 11: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

ResourcesTechnical Communities, Webcasts, Blogs, Chats & User Groupshttp://www.microsoft.com/communities/default.mspx

Microsoft Developer Network (MSDN) & TechNet http://microsoft.com/msdn http://microsoft.com/technet

Trial Software and Virtual Labshttp://www.microsoft.com/technet/downloads/trials/default.mspx

Microsoft Learning and Certificationhttp://www.microsoft.com/learning/default.mspx

Visual C# Developer Centerhttp://msdn2.microsoft.com/en-us/vcsharp/default.aspx

Visual Studio 2008 Beta1 Download Pagehttp://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx

Visual Studio 2008 Sampleshttp://msdn2.microsoft.com/en-us/bb330936.aspx

Page 12: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

Evaluation Forms

Page 13: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

Questions?

Page 14: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

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

Page 15: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

Expression Tree'sBinaryExpressionConstantExpressionFuncletExpressionInvocationExpressionLambdaExpressionMemberExpressionMethodCallExpressionNAryExpressionNewArrayExpressionNewExpressionParameterExpressionTernaryExpressionTypeBinaryExpressionUnaryExpression

Page 16: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

Expression Tree’s

Expression: “a + b”

ParameterExpression a = Expression.Parameter(typeof(int), "a");

ParameterExpression b = Expression.Parameter(typeof(int), "b");

BinaryExpression add = Expression.Add(a, b);Expression<Func<int,int,int>> l =

Expression.Lambda<Func<int,int,int>>(add, a, b);

Console.WriteLine(DoBinOp(l, 1, 2));

Page 17: Joel Pobar Language Geek Microsoft DEV320 Improve on C#2.0 100% Backwards Compatible Language Integrated Query (LINQ)

Expression Tree's

Param“a”

Param“b”

Binary“Add”