SlideShare une entreprise Scribd logo
1  sur  26
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
    application's 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 test




Create 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

Contenu connexe

Tendances

Jdbc (database in java)
Jdbc (database in java)Jdbc (database in java)
Jdbc (database in java)
Maher Abdo
 
Jdbc slide for beginers
Jdbc slide for beginersJdbc slide for beginers
Jdbc slide for beginers
Ambarish Rai
 

Tendances (20)

Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
Jdbc (database in java)
Jdbc (database in java)Jdbc (database in java)
Jdbc (database in java)
 
Jdbc
JdbcJdbc
Jdbc
 
Spring
SpringSpring
Spring
 
Database and Java Database Connectivity
Database and Java Database ConnectivityDatabase and Java Database Connectivity
Database and Java Database Connectivity
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc
JdbcJdbc
Jdbc
 
JDBC Tutorial
JDBC TutorialJDBC Tutorial
JDBC Tutorial
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05
 
Jdbc complete
Jdbc completeJdbc complete
Jdbc complete
 
HIgh Performance Messaging App Development with Oracle Advance Queuing
HIgh Performance Messaging App Development with Oracle Advance QueuingHIgh Performance Messaging App Development with Oracle Advance Queuing
HIgh Performance Messaging App Development with Oracle Advance Queuing
 
Overview Of JDBC
Overview Of JDBCOverview Of JDBC
Overview Of JDBC
 
J2EE PPT --CINTHIYA.M Krishnammal college for women
J2EE PPT --CINTHIYA.M Krishnammal college for womenJ2EE PPT --CINTHIYA.M Krishnammal college for women
J2EE PPT --CINTHIYA.M Krishnammal college for women
 
Jdbc
JdbcJdbc
Jdbc
 
White paper for High Performance Messaging App Dev with Oracle AQ
White paper for High Performance Messaging App Dev with Oracle AQWhite paper for High Performance Messaging App Dev with Oracle AQ
White paper for High Performance Messaging App Dev with Oracle AQ
 
Jdbc slide for beginers
Jdbc slide for beginersJdbc slide for beginers
Jdbc slide for beginers
 
JDBC
JDBCJDBC
JDBC
 
Jdbc drivers
Jdbc driversJdbc drivers
Jdbc drivers
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)
 
jsf2 Notes
jsf2 Notesjsf2 Notes
jsf2 Notes
 

Similaire à Day4

Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
Harman Bajwa
 
Datastage Online Training @ Adithya Elearning
Datastage Online Training @ Adithya ElearningDatastage Online Training @ Adithya Elearning
Datastage Online Training @ Adithya Elearning
shanmukha rao dondapati
 
Ado.net session05
Ado.net session05Ado.net session05
Ado.net session05
Niit Care
 
ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu Vishwakarma
Sonu Vishwakarma
 
Mercury Testdirector8.0 Admin Slides
Mercury Testdirector8.0 Admin SlidesMercury Testdirector8.0 Admin Slides
Mercury Testdirector8.0 Admin Slides
telab
 
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
guest5eed7
 
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
guest5eed7
 
Ado.net session01
Ado.net session01Ado.net session01
Ado.net session01
Niit Care
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentals
Madhuri Kavade
 

Similaire à Day4 (20)

Chap14 ado.net
Chap14 ado.netChap14 ado.net
Chap14 ado.net
 
PPT temp.pptx
PPT temp.pptxPPT temp.pptx
PPT temp.pptx
 
6 database
6 database 6 database
6 database
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
 
Building a Testable Data Access Layer
Building a Testable Data Access LayerBuilding a Testable Data Access Layer
Building a Testable Data Access Layer
 
Datastage Online Training @ Adithya Elearning
Datastage Online Training @ Adithya ElearningDatastage Online Training @ Adithya Elearning
Datastage Online Training @ Adithya Elearning
 
Ado.net session05
Ado.net session05Ado.net session05
Ado.net session05
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
 
ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu Vishwakarma
 
Mercury Testdirector8.0 Admin Slides
Mercury Testdirector8.0 Admin SlidesMercury Testdirector8.0 Admin Slides
Mercury Testdirector8.0 Admin Slides
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
Data access
Data accessData access
Data access
 
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
 
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
 
Ado.net session01
Ado.net session01Ado.net session01
Ado.net session01
 
Deploying data tier applications sql saturday dc
Deploying data tier applications sql saturday dcDeploying data tier applications sql saturday dc
Deploying data tier applications sql saturday dc
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentals
 
Jdbc
JdbcJdbc
Jdbc
 
Ado
AdoAdo
Ado
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
 

Dernier

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Dernier (20)

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 

Day4

  • 1. CSE 136 - Lecture 4 Part 1
  • 3. 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.
  • 4. DAL responsibilities In one transaction: 1. Add new course 2. Update pre-req 3. Delete old course
  • 5. DAL responsibilities - Object Mapping
  • 6. DAL - query service
  • 7. DAL - Transaction Management  Keep track of all significant changes to the application's 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
  • 8. DAL and other layers
  • 9. C# try/catch - exceptions
  • 12. 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
  • 13. ADO.NET - connection and command
  • 14. ADO.NET - Adapter & DataSet
  • 17. Create a unit test Create the DALTest (class library project) first
  • 18. Create unit test code Test the “Insert” Assert: to validate the values match Testing the “Get” Clean up
  • 19. Unit test project – App.config
  • 20. Unit test, assert error, and watch
  • 21. Unit test break point & debug
  • 22. 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?
  • 23. 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
  • 24. 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
  • 25. Lab  Due: Grade your DB setup
  • 26. References  .NET : Architecting Applications for the Enterprise