asp.net 3.5 part 2

19

Click here to load reader

Upload: asim78

Post on 10-May-2015

2.373 views

Category:

Technology


0 download

DESCRIPTION

Asp.Net Introduction

TRANSCRIPT

Page 1: Asp.Net 3.5 Part 2

Building Effective Web Applications with ASP .Net 3.5

ASIM SHAHZAD

Page 2: Asp.Net 3.5 Part 2

Overview of Data Access (Chapter 8)

• 99.99% of apps involve some type of data• We can use data bound controls to

generate our web application’s UI• SQL Server Express is a royalty free

database included with VS2008 or Visual Web Developer.

Page 3: Asp.Net 3.5 Part 2

Types of Data bound Controls p337

• Lists• Tabular• Hierarchical

Page 4: Asp.Net 3.5 Part 2

Bind Controls to a DataSource p350

• SQLDataSource• LinqDataSource• AccessDataSource• ObjectDataSource• XmlDataSource• SiteMapDataSource

Page 5: Asp.Net 3.5 Part 2

Data Driven App Demos

• Code From Chapter 81.Add/Configure a SQLDataSource2.List Controls3.Tabular4.Hierarchical Data

This demo uses an xml file as a data source.

5.CRUD Sample – Employee Directory

Page 6: Asp.Net 3.5 Part 2

Break• We will look discuss LINQ after break

Page 7: Asp.Net 3.5 Part 2

What is LINQ?• LINQ stands for Language Integrated

Query• A general purpose query facility to

query relational data, XML data, objects/collections.

• New in .Net Framework 3.5 – must target .Net Framework 3.5

• Based on standard query operators• LINQ query syntax resembles

backwards SQL statements

Page 8: Asp.Net 3.5 Part 2

LINQ Architecture

.NET Language Integrated QueryC# 3.0C# 3.0 VB 9.0VB 9.0 OthersOthers……

LINQ toLINQ to ObjectsObjects

LINQ toLINQ to SQLSQL

LINQ toLINQ to XMLXML

LINQ toLINQ to DataSetsDataSets

Objects

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

</book>

XMLRelational

Page 9: Asp.Net 3.5 Part 2

Benefits of Using LINQ• May not need to build an entire DAL

(data access layer)• Much easier to query XML – don’t

have to use Xpath• Work with data in a consistent way –

whether it is SQL Server data, XML data, ADO .Net dataset, an object collection, or data in memory

• Offers compile time checking, autocompletion, and Intellisense

Page 10: Asp.Net 3.5 Part 2

New C# Language Features that Support LINQ p902

• Automatic properties• Initializers• Type Inference• Anonymous types

Page 11: Asp.Net 3.5 Part 2

Three Parts of a LINQ Query• Obtain the data source• Create the query• Execute the query

Page 12: Asp.Net 3.5 Part 2

What’s a DataContext?• The DataContext is the source of all

entities mapped over a database connection

• It tracks changes that you made to all retrieved entities and maintains an "identity cache" that guarantees that entities retrieved more than one time are represented by using the same object instance.

Page 13: Asp.Net 3.5 Part 2

LINQ Demos from MSDN Library Help Files

• How to: Query an ArrayList with LINQ• LINQ to XML vs. DOM• Paste as XML C# Addin

Page 14: Asp.Net 3.5 Part 2

C# Building the Paste Xelement as XML Addin

• http://www.hanselman.com/blog/PasteXM LAsXLinqXElementVisualStudioAddIn.asp x

Page 15: Asp.Net 3.5 Part 2

Creating LINQ to SQL Entities• Building Entities with the Object Relational

Designer p922• Using the LINQDataSource control

p926

Page 16: Asp.Net 3.5 Part 2

Other MVC Resources

• MSDN Virtual Lab on Introduction to .Net MVC

• Discussion of .Net MVC can be found on www.asp.net/mvc/

• Book - Design Patterns by Gamma, Helm, Johnson, and Vlissides

Page 17: Asp.Net 3.5 Part 2

Other LINQ resources• www.thinqlinq.com• Book – LINQ in Action• Msdn.microsoft.com articles on LINQ

Page 18: Asp.Net 3.5 Part 2

Optional Take Home Class Exercise

• Do any one of the following:1.MSDN Virtual Lab “Using LINQ to SQL

with the .Net Framework 3.5 and Visual Studio 2008” Event ID: 1032376015

(msevents.microsoft.com)2. Download lab manual from #1, install

Northwind database and do lab on your pc.

3.Do VS2008 Training Kit Lab “LinqToSql”

Page 19: Asp.Net 3.5 Part 2

Questions ?• Feel free to contact me at

[email protected]• Thank you!