ASP.NET 3.5 New Features
Agenda
What's New in .NET Framework 3.5?
Visual Studio 2008 Enhancements
LINQ (Language Integrated Query)
New ASP.NET Server Controls
ASP.NET 3.5 Extensions
ASP.NET Dynamic Data ( now in SP1 )
ASP.NET MVC Framework ( now in Beta )
ASP.NET and AJAX Integration
ASP.NET Controls for Silverlight 2
Timeline
November 2005 ASP.NET 2.0 Released along with Visual Studio 2005 (No ASP.NET AJAX) January 2007 ASP.NET AJAX v1.0 released as an add-on to ASP.NET 2.0 (Works with Visual Studio 2005) May 2007 ASP.NET "Futures" a developer preview of some of the features considered for future releases released as a CTP July 2007 ASP.NET "Futures" CTP Updated November 2007 ASP.NET 3.5 and Visual Studio 2008 released (ASP.NET 3.5 contains built-in newer version of ASP.NET AJAX, ListView, DataPager and LinqDataSource controls) December 2007 ASP.NET 3.5 Exensions (CTP Version containing new features for ASP.NET, AJAX and Silverlight) August 2008 .Net 3.5 SP1
3
What’s New in .NET Framework 3.5?
Language Integrated Queries (LINQ)
Family of technologies that provides querying features for data, from relational to XML
Generate a LINQ object model that provides an object representation of the database
New collections: HashSet
Peer-to-Peer networking framework
Integration of WCF and WWF (Workflow Services) 4
What’s New in Visual Studio 2008?
Framework targeting (2.0, 3.0, 3.5) Full support for LINQ and LINQ to SQL Integrated ASP.NET AJAX Improved HTML editor
Split source/design view JavaScript IntelliSense and debugging CSS manager and debugger
Integrated WPF, WCF, WF designers Runs a bit slower
5
Visual Studio 2008 Enhancements
6
LINQ and LINQ to SQL
Query, set and transform operations for .NET Querying data becomes a core programming concept Works with all types and shapes of data
Works with all .NET languages
Relational databases XML Objects … C# and VB and have integrated language support
LINQ to SQL
Powerful ORM framework
7
Query var contacts = expressions from c in customers where c.State == "WA" Local Expression select new { c.Name, c.Phone }; variable type trees inference
Lambda expressions
Automatic properties
var contacts = Partial customers methods .Where(c => c.State == "WA") .Select(c => new { c.Name, c.Phone }); Extension methods
Anonymous types
Object initializers 8
Dim x = 5
Implicitly typed locals <Extension> Extension methods Sub Randomize(col As Collection) Lambda Expressions Function(c) c.Name Object initializers New Point With { .x = 1, .y = Anonymous types 2} Nullable types New With { c.Name, c.Phone Query expressions } If emp.DOB >= Tod XML Literals ay From … Where … Select
9
SqlConnection c = new SqlConnection(…); Queries in c.Open(); quotes SqlCommand cmd = new SqlCommand( @"SELECT c.Name, c.Phone Loosely FROM Customers c bound WHERE c.City = @p0"); arguments cmd.Parameters["@p0"] = "London"; DataReader dr = c.Execute(cmd); Loosely while (dr.Read()) { typed result string name = dr.GetString(0); sets string phone = dr.GetString(1); DateTime date =dr.GetDateTime(2); } dr.Close(); No compile time checks 10
public class Customer { … }
Classes describe data
public class Northwind: DataContext Tables are { like public Table Customers; collections … } Strongly typed connection Northwind db = new Northwind(…); var contacts = Integrated from c in db.Customers query syntax where c.City == "London" select new { c.Name, c.Phone }; Strongly typed results
11
Integrated, native query syntax in C# and VB
Query Operators can be used against any .NET collection (IEnumerable)
IntelliSense and Autocompletion
Built-in examples: Select, Where, GroupBy, Join, etc. Extensibility model supports extending/replacing these
Deferred Query Evaluation Lambda Expressions
using System; using System.Query; using System.Collections.Generic; class app { static void Main() { string[] string[] names names = { = "Burke", { "Allen", "Connor", "Arthur", "Frank", "Bennett" "Everett", }; "Albert", "George", IEnumerable<string> "Harris", "David" ayes }; = names Func<string, .Where(s bool> => s[0] filter == 'A'); = s => s.Length == 5; IEnumerable<string> Func<string, string>expr extract = = s => s; Func<string, foreach (string string> from item s in names project ayes) = s = s.ToUpper(); Console.WriteLine(item); where s.Length == 5 IEnumerable<string> orderby exprs= names names[0] .Where(filter) = "Bob"; select s.ToUpper(); .OrderBy(extract) foreach foreach .Select(project); (string (string item item inin expr) ayes) Console.WriteLine(item); Console.WriteLine(item); } foreach (string item in expr) } Console.WriteLine(item); } Arthur Allen } Arthur BURKE DAVID FRANK 12
LINQ to SQL
LINQ to SQL Designer in VS 2008
NorthwindDataContext db = new NorthwindDataContext(); var customers = from c in db.Customers where c.City == "London" select c; foreach (var cust in customers) Console.WriteLine( "id = {0}, City = {1}", cust.CustomerID, cust.City);
13
LINQ to Objects API queries over any .NET collection, such as arrays and generic lists. LINQ over XML (XLinq) Core functionality of the XLinq API such as load, modify, and save XML documents LINQ to SQL provides direct access to database tables from the programming environment LINQ to Entities enables developers to use LINQ over EDM models LINQ to Dataset allows the full expressivity of LINQ to be used over Datasets.
14
New ASP.NET Data Controls
15
ListView Control
Combines templating capabilities of the Repeater control and the data editing capabilities of the DataGrid complete control of how the ListView presents your data through 11 templates.
LayoutTemplate AlternatingItemTemplate EditItemTemplate EmptyDataTemplate EmptyItemTemplate GroupTemplate GroupSeparatorTemplate InsertItemTemplate ItemTemplate ItemSeparatorTemplate SelectedItemTemplate
most important templates are the LayoutTemplate and the ItemTemplate. LayoutTemplate HTML defines the overall look and feel ItemTemplate HTML specifies how each bound record will appear.
16
ListView
17
DataPager
provides paging capabilities. points at the control it provides paging support for. As an external control place it anywhere on the page, and configure look works with controls that implement the IPageableItemContainer interface ( ListView )
18
DataPager
19
LinqData Source Control
Bind to a Linq Data Model
20
ASP.NET 3.5 Extensions
ASP.NET MVC Framework
ASP.NET Dynamic Data
Browser history support
ADO.NET Data Services
Dynamic data controls for displaying/editing table data in ASP.NET
ASP.NET AJAX
Model View Controller framework for ASP.NET ( now in Beta )
Create REST addressable services endpoints for your data and consume with AJAX and Silverlight
Silverlight Controls for ASP.NET
Integrate Silverlight into ASP.NET applications
21
ASP.NET Dynamic Data
Create quickly a rich data-driven Web sites
Like in Ruby on Rails and Django (in Python) Based on LINQ to SQL data model Dynamically display data based on the data model of the underlying database Pages are created automatically (zero code)
Based on highly customizable templates Uses dynamic data fields – user controls that render standard data field types
22
ASP.NET Dynamic Data
23
ASP.NET AJAX
v1.0
ASP.NET 2.0 VS 2005
v1.0
v3.5
All AJAX 1.0 features in .NET 3.5
Better Development Experience
ASP.NET 3.5 VS 2008
Enhancements to UpdatePanel WCF JSON Services
JavaScript Intellisense JavaScript Debugging ASP.NET AJAX Extender Control Support
24
ASP.NET AJAX Control Toolkit
Separate download from core ASP.NET AJAX
Developed using a collaborative source model
Library of free ASP.NET AJAX enabled controls Download from http://ajax.asp.net
Licensed under Microsoft Public License (Ms-PL) All source freely available
~ 40 controls as of today
25