Asp.Net 3.5 Part 2


Published on

Asp.Net Introduction

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Asp.Net 3.5 Part 2

  1. 1. Building Effective Web Applications with ASP .Net 3.5 ASIM SHAHZAD
  2. 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.
  3. 3. Types of Data bound Controls p337 • Lists • Tabular • Hierarchical
  4. 4. Bind Controls to a DataSource p350 • SQLDataSource • LinqDataSource • AccessDataSource • ObjectDataSource • XmlDataSource • SiteMapDataSource
  5. 5. Data Driven App Demos • Code From Chapter 8 1.Add/Configure a SQLDataSource 2.List Controls 3.Tabular 4.Hierarchical Data This demo uses an xml file as a data source. 5.CRUD Sample – Employee Directory
  6. 6. Break • We will look discuss LINQ after break
  7. 7. 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
  8. 8. LINQ Architecture C# 3.0 VB 9.0 .NET Language Integrated Query Others… LINQ to LINQ to LINQ to LINQ to Objects DataSets SQL XML <book> <title/> <author/> <year/> <price/> </book> Objects Relational XML
  9. 9. 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
  10. 10. New C# Language Features that Support LINQ p902 • Automatic properties • Initializers • Type Inference • Anonymous types
  11. 11. Three Parts of a LINQ Query • Obtain the data source • Create the query • Execute the query
  12. 12. 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.
  13. 13. LINQ Demos from MSDN Library Help Files • How to: Query an ArrayList with LINQ • LINQ to XML vs. DOM • Paste as XML C# Addin
  14. 14. C# Building the Paste Xelement as XML Addin • LAsXLinqXElementVisualStudioAddIn.asp x
  15. 15. Creating LINQ to SQL Entities • Building Entities with the Object Relational Designer p922 • Using the LINQDataSource control p926
  16. 16. Other MVC Resources • MSDN Virtual Lab on Introduction to .Net MVC • Discussion of .Net MVC can be found on • Book - Design Patterns by Gamma, Helm, Johnson, and Vlissides
  17. 17. Other LINQ resources • • Book – LINQ in Action • articles on LINQ
  18. 18. 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 ( 2. Download lab manual from #1, install Northwind database and do lab on your pc. 3.Do VS2008 Training Kit Lab “LinqToSql”
  19. 19. Questions ? • Feel free to contact me at • Thank you!