Using LINQ to Entities in the data access layer
Now we have the solution, the Entity model, and the connection string. Next we will modify the data access layer to use LINQ to Entities to retrieve and update products. We will first modify GetProduct
to retrieve a product from the database and then modify UpdateProduct
to update a product in the database. In this section the UpdateProduct
method will not have concurrency control. It will simply commit the changes to the database even though the product has been changed by other users. In the upcoming section, Adding concurrency support, we will make further changes to the service so that concurrent updates can be controlled properly.
Modifying GetProduct in the data access layer
We can now modify the GetProduct
method in the data access layer class, ProductDAO
,
to use LINQ to Entities to retrieve a product from the database. Just as we did in the previous chapter, we will first create an Entity, ObjectContext
, and then use LINQ to Entities...