Your SlideShare is downloading. ×
Day4
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Day4

101
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
101
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. CSE 136 - Lecture 4 Part 1
  • 2. What is DAL?
  • 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 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. DAL and other layers
  • 9. C# try/catch - exceptions
  • 10. C# try/catch example
  • 11. C# try/catch in DAL
  • 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
  • 15. ADO.NET - DataSet
  • 16. ADO.NET - summary
  • 17. Create a unit testCreate 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