Skip to content
This repository was archived by the owner on Aug 18, 2021. It is now read-only.

Building complex queries

Gustavo Denis edited this page Oct 31, 2019 · 1 revision
Main > Using Liquid for building your application > Building complex queries

Liquid provides a LightExpression class that abstracts common LINQ expressions and adds the capability to extend those queries to easily build more complex queries.

The user could build the queries dynamically by adding conditions to original query in a intuitive way. The LightExpression class can be cast implicitly to a Expression<Func<T, bool>>

public async Task<DomainResponse> SearchCities(CityViewModel filter)
{
   var query = LightExpression<CityModel>.New();
   if (filter.Name != null)
   {
       query = query.Where(x => x.Name == filter.Name);
   }

   if (filter.Country != null)
   {
      query = query.Where(x => x.Country == filter.Country);
   }

   var result = await Repository.GetAsync<CityModel>(query);
   return Response(result);
}
See how this is done in Liquid Hotel360 sample application.

Clone this wiki locally