Upcoming SlideShare
Loading in...5







Total Views
Slideshare-icon Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Day4 Day4 Presentation Transcript

    • CSE 136 - Lecture 4 Part 1
    • What is DAL?
    • DAL Requirement Database independent  DAL implementation should allow easy swap of database servers (SQL Server to Oracle) Configurable  DAL selection can be controlled by configuration file  Example: connection string should be in web.config file or app.config Persisting the Application Object Model  Save the info in memory (object-oriented data) to disk (relational data)  Example: In windows app, department chair saves his non-finalized version of course planning for next quarter.
    • DAL responsibilities In one transaction: 1. Add new course 2. Update pre-req 3. Delete old course
    • DAL responsibilities - Object Mapping
    • DAL - query service
    • DAL - Transaction Management Keep track of all significant changes to the applications data that occur in a unit of work A unit of work is a logical (business) transaction that groups a number of database calls  Atomic - one indivisible operation  Consistency - no data corruption when failure occurs  Isolated - Other operation can not see the modified data until completion  Durability - successful or failed transaction notification
    • DAL and other layers
    • C# try/catch - exceptions
    • C# try/catch example
    • C# try/catch in DAL
    • ADO.NET A data provider is a set of ADO.NET classes (libraries)  Allows you to access a specific database  Execute SQL commands  Retrieve data  A bridge between your application and database Classes that make up a data provider include:  Connection  Establish a connection to database  Command  Execute SQL commands and stored procedures  DataReader  fast, read-only, forward-only access from a query  DataAdapter  Fill a DataSet***  More on DataSet next
    • ADO.NET - connection and command
    • ADO.NET - Adapter & DataSet
    • ADO.NET - DataSet
    • ADO.NET - summary
    • Create a unit testCreate the DALTest(class library project)first
    • Create unit test code Test the “Insert” Assert: to validate the values match Testing the “Get” Clean up
    • Unit test project – App.config
    • Unit test, assert error, and watch
    • Unit test break point & debug
    • Review question What are the DAL’s major responsibilities? Why would you need transactions in the DAL? Why do you need try catch in DAL? What .NET library will you be using for DAL? Difference between DataSet and DataAdapter? What is assert.equal() method used for? Why do you need to have sql connection string in the app.config when running unit tests?
    • Demo of VS 2010 O/RM Student info & enrollment in stored procedure Students Enrollment in DAL OR/M between database and DAL Run unit test in DAL
    • Your assignment for next week Set up your solution to include the following "Class Library" projects  DataAccessLayer project  BusinessLayer project  BusinessObjects project Develop the Data Access Layer code (CRUD) Unit Tests for your DAL
    • Lab Due: Grade your DB setup
    • References .NET : Architecting Applications for the Enterprise