Good news for .NET DFP developers - working with PQL just got easier. Additional features have just been added to the statement builder in the .NET client library. You can now use a more fluent interface to construct and modify PQL statements in parts. This allows for better query validation and code that's easier to construct:

// Using the statement builder with the PQL service
StatementBuilder statementBuilder = new StatementBuilder()
    .Select("Id, Name")
    .Where("isMissingCreatives = :isMissingCreatives")
    .OrderBy("id ASC")
    .AddValue("isMissingCreatives", true);

These changes also make modifying and reusing your statements much easier. For example, when paging through result sets you can update the offset without having to alter the entire query. This makes paging quick and easy.

// Using the statement builder with getCreativesByStatement
StatementBuilder statementBuilder = new StatementBuilder()
    .Where("advertiser_id = :advertiserId")
    .OrderBy("id ASC")
    .AddValue("advertiserId", myAdvertiserId);

CreativePage page;
do {
  page = creativeService.getCreativesByStatement(
  if(page.results != null)  {
    foreach (Creative creative in page.results) {
      Console.WriteLine("Creative ID: {0}",;
} while (statementBuilder.GetOffset() < page.totalResultSetSize);


If you're already using the statement builder, no immediate changes are needed. The previous functionality is still available, although it is now marked as obsolete.

The only pitfall comes with mixing functionality. If you set the statement builder's query directly, don't attempt to set parts of the query individually. Likewise, if you're building the query in parts, direct access is not allowed.

Stick with one usage or the other - mixing the two will give you an IllegalOperationException.

For more information, you can check out the out the source or examples. If you have any questions about the new statement builder features, feel free to ask us in the developer forum or on our Google+ Developers page.