Microsoft Visual C# Under the Covers: In-Depth C# 3.0Joel PobarLanguage GeekMicrosoft
DEV320
C# 3.0 Design Themes
Improve on C#2.0
100% Backwards Compatible
Language Integrated Query (LINQ)
C# 3.0 Features
demo
Data != Objects
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
Building LINQ
demo
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>
C# 3.0 – New FeaturesLocal Variable Type InferenceObject Initializers
Collection InitializersAnonymous Types
Auto-Implemented PropertiesExtension MethodsLambdasQuery ExpressionsExpression TreesPartial MethodsImplicitly-Typed Arrays
Summary
Motivation
Language Integrated Query
C# 3.0 New Language Features
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
Evaluation Forms
Questions?
© 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.
Expression Tree'sBinaryExpressionConstantExpressionFuncletExpressionInvocationExpressionLambdaExpressionMemberExpressionMethodCallExpressionNAryExpressionNewArrayExpressionNewExpressionParameterExpressionTernaryExpressionTypeBinaryExpressionUnaryExpression
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));
Expression Tree's
Param“a”
Param“b”
Binary“Add”