Now that you have some background on options for creating a data access layer, this section describes the design pattern for using LINQ to SQL in a three-layered architecture. The pattern uses the DataContext to handle communication with the database, and the entity objects created from the ORM Designer to handle communication with the BLL.
Conceptually, the design pattern is shown in Figure 2-6.
Figure 2.6. Figure 2-6
In keeping with the three-layered design, this pattern has a DAL class library that uses the DataContext object created by the ORM Designer to handle all communication with the database, and uses stored procedures to access the data. Prior to Visual Studio 2008, this would have been handled by the SqlHelper class. The method of communication between the BLL and the DAL will be a mix of entity objects created by the ORM Designer and scalar values. Entity objects are used to pass data back to the BLL, and scalar values are used to pass data into the DAL for insert, update, and delete commands.
All tables will have six standard fields. The first field is the primary key, and the naming convention is TableNameId. The other five fields are InsertDate, InsertENTUserAccountId, UpdateDate, UpdateENTUserAccountId, and the Version. The Version field is a timestamp field. None of the fields allow nulls.
All tables will have five standard stored procedures. The ...