This video is available to students only

Specification Pattern Walkthrough

In this lesson, we're going to walk through the entire process of Specification pattern

Specification Pattern walkthrough#

Although we might say we haven't made any progress in terms of what we have achieved as a result, we still have two repositories which retrieve the same data from the backend. However, if you see it from a perspective of a big project, you have set the foundation by creating generic repository and specification. Anyways, the purpose of this lesson is to take you through the journey from getting a request to sending the data back to the user.

Let's open our CoursesController and look at our GetCourse method. So we receive a request, and we pass id to our CourseWithCategoriesSpecification. Now let's go inside. Our CourseWithCategoriesSpecification implements the BaseSpecification. We have two constructors inside our BaseSpecification; one is the empty one, another one takes a criteria. We are using the empty one in our List methods and the criteria one in the getbyid method. On top, we're passing id to our expression, and inside base, we're using our expression. If we look at our BaseSpecification, this is the base method where we're passing the expression.

Start a new discussion. All notification go to the author.