whenNotNull<T extends Object> method

MssqlQuery whenNotNull<T extends Object>(
  1. T? value,
  2. MssqlQuery build(
    1. MssqlQuery query,
    2. T value
    )
)

Applies build when value is not null, handing it to the callback already promoted to its non-nullable type.

whenNotNull(search, (q, s) => q.where(Col('Name').like(s))) is the shape a filter almost always takes, and it saves the ! that when would otherwise need.

Implementation

MssqlQuery whenNotNull<T extends Object>(
  T? value,
  MssqlQuery Function(MssqlQuery query, T value) build,
) => value == null ? this : build(this, value);