From the course: Building and Securing RESTful APIs in ASP.NET Core
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Extend search to other types - ASP.NET Core Tutorial
From the course: Building and Securing RESTful APIs in ASP.NET Core
Extend search to other types
- [Instructor] The search expressions that come over the wire in the request query string, are strings. In order to search against other property types like numbers, we'll need to cast the string values to the correct destination type. Since we'll need to potentially handle a number of different types, let's create a separate set of classes that can handle converting the search value into a link expression. I'm going to create an interface in the Infrastructure folder called ISearchExpressionProvider. The search expression provider interface will have one method, which returns a constant expression, which we'll need to import from the expressions namespace, and we'll call this GetValue, for our particular string input, and we'll create a default implementation called DefaultSearchExpressionProvider. We'll implement this method. This default implementation will do exactly what our existing Apply method does right now, which is put that string into the constant expression and return it,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.