LINQ to SQL Integrated Code Review
Define Custom DataContext Class
Code Review
- LINQ to SQL Integrated Code Review: Define Person, Role and Salary Classes
- LINQ to SQL Integrated Code Review: Mapping the Class and Database Objects Using XML Mapping File
- LINQ to SQL Integrated Code Review: Define Custom DataContext Class
- LINQ to SQL Integrated Code Review: Manipulate the Database using the DataContext Object
Code Walkthrough
Define the DataContext class, which is used to connect to a database, retrieve objects from it, and submit changes back to it. The purpose of the DataContext is to translate requests for objects into SQL queries to be made against the database, and then to assemble objects out of the results.
The PeopleDataContext class inherits from the DataContext class. Create a class constructor that inherits from the base DataContext constructor, accepting a connection string and a XML mapping file as input parameters. The XML mapping file defines the relationship between the database data model and the application object model.
Printer Friendly Version
Add to Favourites
DotNet Kicks
Digg
del.icio.us
Live Favourites
ma.gnolia
reddit
Slashdot
Technorati
Yahoo!