Replacing your LINQ data access layer with QueryExpressions
Given that we have refactored our plugin in the previous recipe, we will now demonstrate how easy it is to swap a concrete DAL class with an alternative implementation.
In this recipe, we will replace the LINQ EmailDataAccessLayer
implementation with a QueryExpression
implementation. We will also drop the unit of the work design pattern and use IOrganizationService
instead of OrganisationServiceContext
.
Getting ready
To implement this recipe, we will need the existing code structure from the previous recipe. If you are starting from scratch, you can follow the code structure from the previous recipe and replace the implementation with your own code.
As with any recipe that deals with C# code, it is strongly recommended that you use a stable version of Visual Studio. In our example, we will be using Visual Studio 2015.
How to do it...
- Create a new public class called
EmailDataAccessLayerQueryExpression
in theDataAccessLayer
folder that...