when method

MssqlQuery when(
  1. bool condition,
  2. MssqlQuery build(
    1. MssqlQuery query
    ), {
  3. MssqlQuery otherwise(
    1. MssqlQuery query
    )?,
})

Applies build only when condition holds.

Keeps conditional filters in the fluent chain. otherwise handles the false branch.

Implementation

MssqlQuery when(
  bool condition,
  MssqlQuery Function(MssqlQuery query) build, {
  MssqlQuery Function(MssqlQuery query)? otherwise,
}) {
  if (condition) return build(this);
  return otherwise == null ? this : otherwise(this);
}