public function toQuery( Query $query, array $columns = [], $alias = '' ) {

		foreach( $this->criteria as $column => $criteria ) {

			if( !$column = $this->getColumnName($columns, $column, $alias) )
				continue;

			foreach( $criteria as $operator => $value ) {
				$query->where($column, $operator, $value);
			}

		}

		foreach( $this->getOrder() as $column => $ascending ) {
			$column = $this->getColumnName($columns, $column, $alias);
			if( !$column )
				continue;
			$query->orderBy($column, $ascending);
		}

		if( $this->offset )
			$query->offset($this->offset);

		if( $this->limit )
			$query->limit($this->limit);

		return $query;

	}