CSE 136 - Lecture 4 Part 1
What is DAL?
DAL Requirement   Database independent       DAL implementation should allow easy swap of        database servers (SQL S...
DAL responsibilities                       In one transaction:                       1. Add new 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 ...
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       ...
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                 ...
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...
Demo of VS 2010 O/RM   Student info & enrollment in stored procedure   Students Enrollment in DAL   OR/M between databa...
Your assignment for next week   Set up your solution to include the following    "Class Library" projects     DataAccess...
Lab   Due: Grade your DB setup
References   .NET : Architecting Applications for the    Enterprise
Upcoming SlideShare
Loading in …5
×

Day4

230 views

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
230
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Day4

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

×